Solved

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

Posted on 2008-06-17
4
3,160 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

[b]Ok so now I will show you how to add a user name to the description at login. [/b] First connect to your DC (Domain Controller / Active Directory Server) SET PERMISSIONS FOR SCRIPT TO UPDATE COMPUTER DESCRIPTION TO USERNAME 1. Open Active …
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

805 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