Getting Members of an Active Directory Group

Over the last few weeks, I’ve found myself wanting to know which users are members of a particular Active Directory (AD) group. There are lots of reasons you might want to do this, but for me, the main one is that I sometimes need to know who has access to an application or resource (which is controlled by that group’s membership list). With that, I can let them know about outages, find out if other users are experiencing a problem with it or just be nosey :-) In Powershell, this is really easy. One way is like this, using the [Get-ADGroupMember](https://technet.microsoft.com/en-us/library/ee617193.aspx) command:

Get-ADGroupMember -identity "group-name-to-search-for" | select name

This will return results similar to the following:

name
----
SMoon
JBloggs
JBieber
DCameron

Another way is using the [net group](https://technet.microsoft.com/en-us/library/cc754051.aspx) command:

NET GROUP "group-name-to-search-for" /DOMAIN

which returns results in a more columnar fashion:

Members
SMoon JBloggs JBieber DCameron

Need the results saved into a text file? That’s no problem, either. Just append the following onto the end of the command:

| Export-csv -path c:\Temp\output.csv -NoTypeInformation

That line (|) in the example above is the pipe symbol. On my keyboard, I find it next to the “z” key and access it by pressing shift. Just for clarity, here’s the Get-ADGroupMember command again using it.

Get-ADGroupMember -identity "group-name-to-search-for" | select name | Export-csv -path c:\Temp\output.csv -NoTypeInformation

So, now you know!


Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’ logicalmoon.com