every1isevil2
asked on
Need correct syntax for DSQUERY and DSGET operation.
I need to query a specific group in our AD forest call "Part-time staff" to return the user name(CN) and smtp email addresses of those users to a text file. I have been experimenting with this and have not been able to get the results I need.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can do a:
dsget user /?
to see what you can extract. The DN is kind of large. You can also return samid or display as well:
dsquery group -name "Part-time staff" | dsget group -members | dsget user -samid -email
dsquery group -name "Part-time staff" | dsget group -members | dsget user -display -email
dsget user /?
to see what you can extract. The DN is kind of large. You can also return samid or display as well:
dsquery group -name "Part-time staff" | dsget group -members | dsget user -samid -email
dsquery group -name "Part-time staff" | dsget group -members | dsget user -display -email
To redirect to a text file you just add:
>yourtextfile.txt
...to the end.
e.g.
dsquery group -name "Part-time staff" | dsget group -members | dsget user -display -email>PartTimeStaff.txt
>yourtextfile.txt
...to the end.
e.g.
dsquery group -name "Part-time staff" | dsget group -members | dsget user -display -email>PartTimeStaff.txt
ASKER
Pber:
Wondeful. Work sperfectly!
Just one follow up. Is there a way to tweak the results to get only the 'CN=First Last' portion? Right now it gives me:
CN=First Last,OU=Users,OU=Staff,OU= MCC,DC=sta ff,DC=mort on,DC=edu
Frist.Last@myschool.edu
Which is FINE considering I was not able to get this before. Thanks again.
Wondeful. Work sperfectly!
Just one follow up. Is there a way to tweak the results to get only the 'CN=First Last' portion? Right now it gives me:
CN=First Last,OU=Users,OU=Staff,OU=
Frist.Last@myschool.edu
Which is FINE considering I was not able to get this before. Thanks again.
ASKER
This did the trick thanks again!
dsquery group -name "#Part-time faculty" | dsget group -members | dsget user -display -email
dsquery group -name "#Part-time faculty" | dsget group -members | dsget user -display -email
glad to help.
I get that command to work on most of my security group except for staff. Maybe because staff have more than 3000 + users. Please advise
dsquery group -name Staff | dsget group -members | dsget user -email >c:\file.txt
dsquery group -name Staff | dsget group -members | dsget user -email >c:\file.txt
C:\>dsquery group -name "staff" | dsget group -members | dsget user -display -em
ail >c:\Staff.txt
dsget failed:The parameter is incorrect.
ail >c:\Staff.txt
dsget failed:The parameter is incorrect.
The problem might be you have a nested group or other objects that may not be compliant. You can add the flag (-c) to continue on errors it should work.
dsquery group -name Staff | dsget group -members -c | dsget user -emai -c l >c:\file.txt
dsquery group -name Staff | dsget group -members -c | dsget user -emai -c l >c:\file.txt
dsquery group -name "Part-time staff" | dsget group -members -expand
The -expand on the end is optional if you want to show the membership of nested groups