Question: I'm trying to script something where I can get the email address of all users in an active directory security group.

What I have so far:

```
$Groups = Get-ADGroup -filter {Name -like "VIPEmail" } | Select-Object Name
ForEach ($Group in $Groups) {
  Get-ADGroupMember -identity $($group.name) -recursive | Select-Object samaccountname
}

```

Obviously this will only return the samaccountname, which it does. I replace samaccountname with EmailAddress, and it does nothing.

Answer: 
Something like this:'

```
Get-ADGroup -filter {name -like 'VIPEmail'} | 
Get-ADGroupMember -Recursive |
Get-ADUser -Properties Mail |
select -ExpandProperty Mail

```
I'd add unique. So when a user is in more groups only one email is shown:

```
Get-ADGroup -filter {Name -like "RO*" } | 
Get-ADGroupMember -Recursive | 
select -Unique| 
get-adUser -Properties mail |
select -ExpandProperty Mail

```