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?



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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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