Can DSQUERY commands be piped together?

eg to return a list of users in each of the groups found within the 'Builtin' container?

dsquery groups "cn=Builtin,dc=domain,dc=company" | dsquery groups "cn=%builtingroups%cn=Builtin,dc=domain,dc=company" -members >>usergroups.txt

Where %builtingroups% is the result of the first query (ie a list of groups)

Thanks!

link|improve this question
I think this question is similar but doesn't return the result i'm looking for (ie a user list within every group contained per container) – HaydnWVN Jan 9 at 12:44
feedback

1 Answer

for /f "usebackq delims=" %a in (`dsquery group "cn=Builtin,dc=domain,dc=company"`) do echo ===%a members: >> members.txt && dsget group %a -members >> members.txt
link|improve this answer
thanks, i'll try it later! Care to explain what each part does? I can partly figure it out myself... :) – HaydnWVN Jan 10 at 13:10
Well, it gets list of groups with "dsquery group", then it goes through that list and for each line calls dsget to pick members. "echo ... &&" is just to make output more readable so you can omit that. Type "for /?" for usebackq and delims explanation. It will be more clear when you look at it running. – dusan.bajic Jan 10 at 13:27
Excellent, thanks! :) – HaydnWVN Jan 10 at 13:40
dsquery failed:A referral was returned from the server. Any ideas to troubleshoot? – HaydnWVN Jan 11 at 19:44
try dsquery alone: dsquery group "cn=Builtin,dc=domain,dc=company", it is usually a typing error – dusan.bajic Jan 12 at 13:24
show 2 more comments
feedback

Your Answer

 
or
required, but never shown

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