Solved

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

Posted on 2008-06-17
4
3,304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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