To get adgroupmember name and email address from the active directory, use the Get-AdGroupMember cmdlet and use the parameter Recursive to get members including the child groups.
Get-AdUser cmdlet is used to get the names and email addresses of the members of the adgroup.
The Get-AdGroupMember doesn’t provide a way to get the Name and email address of the members, hence its result should be piped to the Get-AdUser cmdlet to select the name and email address property.
In this article, we will discuss how to get adgroupmember name and email address using the Get-AdGroupMember cmdlet.
Get AdGroupMember Name and Email Address
To get all members from the group and child group of a particular security or distribution group, use the Get-AdGroupMember with the parameter Recursive.
Get-ADGroupMember -Identity "SALESLEADER" -Recursive | Get-ADUser -Properties Name,Mail | Select-Object Name, Mail
In the above PowerShell script, the Get-AdGroupMember cmdlet uses the Identity parameter to specify the group and the Recursive parameter to get all members from the ad group including child groups.
It piped the result to the Get-AdUser cmdlet to get adgroupmember name and email address properties.
The output of the above PowerShell script to get ad group member name and email address is:
I hope the above article on how to get adgroupmember name and email address using the Get-AdGroupMember and Get-AdUser cmdlets is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.