Solved

dsget group piped to dsget user gives an error on groups in the group

Posted on 2008-06-17
4
3,234 Views
Last Modified: 2011-04-19
I need to find all usernames and display names in a group.
C:\>dsget group "CN=thegroup,OU=firstfloor,DC=company,DC=com" -members -expand | dsget user -samid -display
It works but if theres a group inside the group i get an error:
"dsget failed:CN=office,OU=groups,OU=department2,DC=server34,DC=company,DC=com:T
he object class of the target does not match the one specified on the command li
ne."

I think i get this error because one of the members in the group is a group..but isnt there any way of only getting the users?
0
Comment
Question by:bergsprekken
4 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 21802695
I don't know of a way to do this using DSGET, though you could append a -c switch to the end to continue in spite of the errors.

You might have to use vbscript, with something like this as a starting point:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0419.mspx
0
 
LVL 31

Expert Comment

by:Henrik Johansson
ID: 21803191
The error occurs when "dsget user" is used on group-objects. The -c switch is neaded to continue when error occurs, but the error message will still be displayed if not using 2>nul to throuw away stderr

C:\>dsget group "CN=thegroup,OU=firstfloor,DC=company,DC=com" -members -expand | dsget user -samid -display -c 2>nul


Another solution that can be used when the groups are located in dedicated OUs is to pipe the result through find-command to exclude those lines before using "dsget user".

C:\>dsget group "CN=thegroup,OU=firstfloor,DC=company,DC=com" -members -expand | find /i /v "ou=group" | dsget user -samid -display
0
 
LVL 26

Expert Comment

by:farhankazi
ID: 21803198
Try this:

DSQuery * -Filter "(&(objectCategory=Person)(objectClass=User)(memberOf=CN=thegroup,OU=firstfloor,DC=company,DC=com))" -Attr samAccountName displayName

Open in new window

0
 

Expert Comment

by:peterBang
ID: 35422952
C:\>dsget group "CN=thegroup,OU=firstfloor,DC=company,DC=com" -members -expand | find /i /v "ou=group" | dsget user -samid -display

It doesn't works, it's displays "FIND: Format incorrect parameter"


0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In-place Upgrading Dirsync to Azure AD Connect
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question