Microsoft Entra Suite Tech Accelerator
Aug 14 2024, 07:00 AM - 09:30 AM (PDT)
Microsoft Tech Community

How the export Azure AD security group members email addresses into CSV?

Copper Contributor
Hi Forum,

How the export Azure AD security group members email addresses into CSV?

I tried this PowerShell command:

Get-AzureADGroupMember -ObjectId "xxxx...." | Export-csv -path C:\Temp\Output.csv

But, It only generated IDs. How can I get the members email addresses?

please, Let me know!
6 Replies

Get-AzureADGroupMember -ObjectId "xxxxx" | select mail | Export-Csv

If you'd like to export all attributes of the users, run this:

Get-AzureADGroupMember -ObjectId "xxxxx" | fl | Export-Csv

you'll want to pipe in between there the get-azureaduser in between there to get the user details. so something like get-azureadgroupmember -objectid "xxx" | get-azureaduser | export etc. etc.

There's no need for that, as the AAD module returns the full object, it's simply not shown in the default formatting. So for example, this will do the trick:


Get-AzureADGroupMember -ObjectId 84b18857-3c01-48be-b707-492019c57142 | select UserPrincipalName,ProxyAddresses | Export-Csv -nti blabla.csv

actually Max's response would work too, I was still asleep this morning, I would take back my response lol.

Is there a way to run this script so that I don't have to look up the objectID every time I run the script. I want to run this based on principal name (Email Address).

How about this to allow you to input the email address of the group?

$groupmail = Read-Host -Prompt "Enter the group email address"
$groupfind = Get-AzureADGroup -All $true | Where-Object { $_.mail -eq $groupmail }
Get-AzureADGroup -ObjectId $groupfind.ObjectId | Get-AzureADGroupMember

You can also try this script - it will output all Azure AD groups and members - easily modified to include additonal information in the output.