Export AAD Users to CSV

Require to export AAD Users to CSV then we have you covered. I have had this request numerous different times. However, in my experience its most commonly for HR when licensing figures are screwed vs HR employee count. Which is possible the same reason you have even landed on this page today.

Export AAD Users to CSV

How To: Export AAD Users to CSV

Firstly, we have to connect to Azure AD via PowerShell to complete this task. This can be completed by running the below command. You will have to then authenticate with an admin account with sufficient privileges. Please note if you only return yourself as a user then you do not have appropriate permissions.


Secondly. once connected the below command will pull back all Azure AD Users and select the attributes for UserPrincipalName and Mail and store it under the variable $Data.

$Data = Get-AzureADUser -All $true | Select-Object UserPrincipalName,Mail

If you run the below command you can verify the data captured to see if this is as required. Also, its common practice to do this prior to the export to ensure your happy with the data.


Finally, running the following command will export all the details stored in the variable $Data to CSV file

$Data | Export-Csv C:\Temp\UserExport.CSV -NoTypeInformation -Encoding UTF8

The below is copied directly from the CSV Exported above to demo what you expect the CSV to look like.

Export as per C:\Temp\UserExport.CSV

Hopefully the above has helped you export all Users to CSV and completed the task you landed on this page for in the first place.

Additional Details: Azure AD

If you want to find more details please visit the attached tech net article from Microsoft for more details.

Also, if you want to find more details out on how AAD Connect please check out my other blog posts. Furthermore being from a consultant in this area. Shortly, I am hoping to have numerous blog posts on the AAD Connect subject and Transformation rules.

Finally please feel free to drop a comment below or share this blog post if it has helped you.

Please Leave a Comment

If the above has helped you in increase the efficiency in a mailbox migration then please let us know by leaving a comment or feel free to share the article below. If you have any errors or require more details on anything covered then please comment.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *