Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I write a dsquery to get a list of all the members of a d-list, expanding any nested groups to get the members of those groups?

I've written this:

dsquery * -filter "(&(memberOf=cn=...))" -r -limit 0 -attr 
CUSTOMFIELD sAMAccountName displayName > export.txt

but returns nested d-lists and I want to expand these.

I then tried this:

dsquery group -samid "NAME | dsget group -members -expand > export.txt

But this just lists the OU of each member and I want to get the Account Name and a custom field returned.

Is there any way, either of chosing which fields to return from dsget or to epxand dsquery to show nested group membership?

Thanks.

share|improve this question

See "dsget group /?" for an example.

dsget group "CN=DL1,OU=Whatever,DC=Domain,DC=Com" -members -expand

The above should work. But it will spit nested DL names along with members of them.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.