Get Members of AD Group in PowerShell

Get-ADGroupMember command in a Windows PowerShell is used to get the members of an Active Directory (AD) group.

To able to get the AD group members using the ADGroupMember command you need to have an “Active Directory Users and Computers” tool installed and you should be logged into a domain-joined computer as an Active Directory user with the relevant permission.

In this note i will show how to get the AD group members using the ADGroupMember command from the PowerShell.

Cool Tip: How to get Active Directory groups using PowerShell! Read more →

Get Members of AD Group in PowerShell

To get the members of an AD group in the domain the computer is connected to, use the PowerShell’s Get-ADGroupMember command as follows:

PS C:\> Get-ADGroupMember -Identity "<groupName>"

If the AD group which members you need to get is in another domain, add the Server parameter:

PS C:\> Get-ADGroupMember -Identity "<groupName>" -Server <domain>

To get the sorted list of the AD group member names only:

PS C:\> Get-ADGroupMember -Identity "<groupName>" | Select Name | Sort Name

To extract the every member of the “nested” AD group (when another groups are among the group members), add the Recursive attribute:

PS C:\> Get-ADGroupMember -Identity "<groupName>" -Recursive | Select Name | Sort Name

If you are getting an error as follows while trying to execute the commands above, you need to install the Active Directory Users and Computers on your computer:

Get-ADGroupMember : The term ‘Get-ADGroupMember’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Cool Tip: Find out what domain controller am i connected to! Read more →

Leave a Reply