Home » PowerShell » Get AdGroupMember Name and Email Address

Get AdGroupMember Name and Email Address

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:

Get AdGroupMember name and email address
Get AdGroupMember name and email address

Get AdGroup Member First Name and Last Name

To get adgroup member’s first name and last name, use the Get-AdGroupMember command to get members of the group and pipe into the Get-AdUser command to select the member’s first and last name.

Get-ADGroupMember -Identity "DL-Sales" | Get-ADUser | select givenname, surname, userprincipalname

The above command gets all the members of the group and pipes into the Get-AdUser cmdlet to get aduser information and select the adgroup member’s first name, last name, and userprincipalname.

Conclusion

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.