You’ll often need a quick way to get the names of users in a particular Active Directory group into a text or Excel file for reporting or other reasons. You can use dsquery to achieve this easily:
dsquery group -name "group name" | dsget group -members -expand | dsget user -fn -ln
Of course you can also change the ‘dsget user -fn -ln’ to display or remove attributes, eg ‘dsget user -samid’ will show the username. You can also pipe this into a text file.
Possibly related posts (auto generated):
Related Articles
2 users responded in this post
You don’t get any nested members though — only the immediate members.
Yes, that’s right – unfortunately in this case we’d need to drop the last dsget command and just use ‘dsquery group -name “group name” | dsget group -members -expand’ then do a bit of manual manipulation in Excel!
Leave A Reply