Forum Discussion

Samer Forever's avatar
Samer Forever
Copper Contributor
Jul 23, 2018

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

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!
  • 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

      • Deleted's avatar
        Deleted
        actually Max's response would work too, I was still asleep this morning, I would take back my response lol.
  • Max Fritz's avatar
    Max Fritz
    Iron Contributor

    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

    • whatch's avatar
      whatch
      Copper Contributor

      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).

Resources