Solved

Need correct syntax for DSQUERY and DSGET operation.

Posted on 2008-10-07
10
1,187 Views
Last Modified: 2013-12-24
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.
0
Comment
Question by:every1isevil2
[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
  • 6
  • 2
  • 2
10 Comments
 
LVL 26

Expert Comment

by:Pber
ID: 22662392
Try this:
 
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
0
 
LVL 26

Accepted Solution

by:
Pber earned 125 total points
ID: 22662442
woops, you need tne SMTP as well:
dsquery group -name "Part-time staff" | dsget group -members | dsget user -dn -email
 
0
 
LVL 26

Expert Comment

by:Pber
ID: 22662468
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
 
0
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

 
LVL 26

Expert Comment

by:Pber
ID: 22662505
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
0
 
LVL 4

Author Comment

by:every1isevil2
ID: 22662542
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=staff,DC=morton,DC=edu
Frist.Last@myschool.edu

Which is FINE considering I was not able to get this before.  Thanks again.
0
 
LVL 4

Author Comment

by:every1isevil2
ID: 22662653
This did the trick thanks again!

dsquery group -name "#Part-time faculty" | dsget group -members | dsget user -display -email
0
 
LVL 26

Expert Comment

by:Pber
ID: 22662694
glad to help.
0
 

Expert Comment

by:klfinkley
ID: 37458207
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  
0
 

Expert Comment

by:klfinkley
ID: 37458249
C:\>dsquery group -name "staff" | dsget group -members | dsget user -display -em
ail >c:\Staff.txt
dsget failed:The parameter is incorrect.
0
 
LVL 26

Expert Comment

by:Pber
ID: 37461278
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  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

726 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