Skip to main content
(v2) Export AzureAD users to CSV file
Reg Gray avatar
Written by Reg Gray
Updated over a week ago

Export AzureAD users to CSV file

Introduction

This guide is aimed at exporting the user list from Azure AD to a CSV file.

The guide is describing the use of PowerShell and the methods on how use it and which commands necessary to get the module needed.

Get the Azure AD module

Make sure Azure AD PowerShell module is installed with Install-Module -Name Azure AD

Connect using Connect-AzureAD -confirm

Write AD users to C:\users.csv with Get-AzureADUser | Select-Object GivenName,Surname,UserPrincipalName | ConvertTo-csv -NoTypeInformation | Out-File C:\users.csv

  • If AzureAD powershell module is not installed, start powershell as Administrator:

image.png
  • Install AzureAD module with the command Install-Module -Name AzureAD:

image.png
  • When Azure AD Module is installed, Connect to the AD using Connect-AzureAD, you can connect in different ways described in the Microsoft article, easiest is just Connect-AzureAD -Confirm (sign in using an account that has access rights to read users, maybe an admin account):

image.png

Get users and convert to CSV format

Get AD Users with Get-AzureADUser and select the fields you want, then convert to CSV and put in a file.

For example, to get ADUsers and their GivenName, SurName, Email and convert it to CSV and write it to a file, you could run:

Get-AzureADUser | Select-Object GivenName,Surname,UserPrincipalName | ConvertTo-csv -NoTypeInformation | Out-File C:\users.csv

image.png
image.png

If you want to add a field like a preset password you can insert it as so (the newline between the label and expression is required): Get-AzureADUser | Select-Object GivenName,Surname,UserPrincipalName, @{Label = "Password"
Expression = {"temporaryPassword"}} | ConvertTo-csv -NoTypeInformation | Out-File C:\users.csv

image.png
image.png

Microsoft Documentation:

Connect to AzureAD

Did this answer your question?