@Geo Thomas ,
As far as i understand you require Userprincipal names of all the users within your Azure AD organization. You can use the following script to get the output . You require Azure AD PowerShell
Module installed on your machine where you run the following script. Please use the following cmdlet for installing Azure AD PowerShell module.
Install-Module AzureAD
In case you require more information on how to install the powershell module , please check the article how to install Azure AD powershell . You would require to update the variable named $tid which is tenant ID for your tenant . You can find the same using Azure portal .
$tid = 'xxxxx-xxx-xxx-xxx-xxxx' # Please add your tenant ID inside single quotes here.
Connect-AzureAD -TenantId $tid
$allUsers = Get-AzureADUser -All $true
$allUsers.Count
$userInfo = @()
$uid = 0
for($x = 0; $x -le $allUsers.Count; $x++)
{
Write-Progress -Id 0 -Activity "Retrieving User " -Status "$uid of $($allUsers.Count)"
$userInfo += ($allUsers)[$x] | Select-Object -Property *
$uid++
}
Write-Progress -Id 0 -Activity " " -Status " " -Completed
$userInfo | Select DisplayName, AccountEnabled, UserPrincipalName| Format-Table
$userInfo | Select DisplayName, AccountEnabled, UserPrincipalName| Export-Csv ./AADusers.csv -NoTypeInformation -Append
Once you run the script a file named AADUsers.csv will be created in the working directory which will have an output like below.
You can update the script with the properties you would like to see in addition to userprincipalname in the line 14 and 15 in the above script and this will work for you . Hope this is helpful . Should you need more information please do let us know and we will be happy to help you further on this. In case the information is helpful , please do accept the post as answer which will improve the relevancy of the post and improve discoverability of this thread within the forum for others looking for answer on similar issues .
Thank you .
----------------------------------------------------------------------------------------------------------------------------------------------------------
- Please don't forget to click on
whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
- Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators