Getting a list of all users with user properties
This recipe outlines how to retrieve a list of all users in your Microsoft 365 tenant along with their user properties using the Microsoft Graph PowerShell SDK. This can be valuable for audits, compliance checks, or general administrative overviews.
Getting ready
Follow the guidance in the Setting up PowerShell recipe from Chapter 1, Microsoft 365 Setup and Basic Administration, to connect to your Microsoft 365 tenant via PowerShell. Ensure you have administrative privileges on your system, as well as administrative permissions to modify user profiles in your Microsoft 365 tenant such as User Administrator or Global Administrator.
How to do it…
Run the Get-MgUser
cmdlet with selected properties to retrieve information about all users:
Get-MgUser -All | Format-Table DisplayName, UserPrincipalName, JobTitle, Department
How it works…
The Get-MgUser
cmdlet fetches users from your Microsoft 365 tenant. You...