Exporting Security Group Memberships in Batch

active-directorybatchwindows-server-2008-r2

I have the following command but it doesn't work when put into a batch file:

dsquery group DC=domain,DC=com -name "Group Name" | dsget group -members | dsget user -display >> "Group Name.txt"

If I execute through cmd line it works fine but not when executed from within a batch, what am I missing?

(Note: Powershell isn't an option otherwise I would use that believe me !)

Best Answer

Try doing it without the OU / Path to the object. I know it is often encourage to use it, but it seems to cause me trouble more often than not with DSTools.

dsquery group -name "The Group in Question" | dsget group -members | dsget user -display >> "Group Name.txt"

I just tested this, and it did work for my group from a batch File.