Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-17
4
Medium Priority
?
3,485 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 1500 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:Farhan Kazi
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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

Here's a look at newsworthy articles and community happenings during the last month.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

782 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