Link to home
Start Free TrialLog in
Avatar of DESIGNUTT
DESIGNUTTFlag for United States of America

asked on

using AD dsquery, I need a user list with group membership piped to a file.

I am trying to use the cmd line for dsquery | dsget. The ultimates results that will be useful to me is 1. the user 2. what groups it is a member of. I have tried:
dsquery user "ou=users,ou=SubOU,dc=domain,dc=com" -o dn | dsget user -memberof > Z:\users.txt
*this gives me the groups, but I can't tell which user it belong to.

dsquery user "ou=users,ou=SubOU,dc=domain,dc=com" -o dn | dsget user -display > z:\users.txt
*this one shows all the users in the OU, but no group membership!

I need something like
User1
 - group1
 - group2
User2
 - group1
 - group3
 - group4
User3
 - group2
 - group3
 - group5
etc...

If possible, I'd like to do this from the command line using dsquery and dsget.
thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DESIGNUTT

ASKER

Thank you for the reply. I ran your script, I get 2 outputs (one of them for users, one of them for groups). Now, how do I match them up? I would like to show which user is a member of which of the groups. thanks for all the assistance.
I reran this script. This is what I needed. Thanks so much!! You made my day a little easier.