Info
Prerequisites: Install the AzureAD module: Install-Module -Name AzureAD. Connect first: Connect-AzureAD
Basic User Query
powershell
# Retrieve the user object based on UPN
$upn = Read-Host 'Enter user email (user@domain.com)'
$user = Get-AzureADUser -Filter "UserPrincipalName eq '$upn'"
# Display all properties of the user
$user | Format-List *
Extended Properties Query
powershell
$upn = Read-Host 'Enter user email (user@domain.com)'
$user = Get-AzureADUser -Filter "UserPrincipalName eq '$upn'"
$extensions = Get-AzureADUserExtension -ObjectId $user.ObjectId
$extensions | Format-List
Available Properties Reference
Basic Information
ObjectId- Unique identifierUserPrincipalName- User's UPNDisplayName- Display nameGivenName- First nameSurname- Last nameMail- Email addressJobTitle- Job titleDepartment- DepartmentCompanyName- Company name
Contact Information
TelephoneNumber- Phone numberMobile- Mobile phoneStreetAddress- Street addressCity- CityState- State/ProvincePostalCode- Postal codeCountry- Country/Region
Organization
Manager- User's managerDirectReports- Direct reportsMemberOf- Group memberships
Authentication & Security
PasswordPolicies- Password policiesPasswordProfile- Password profileAccountEnabled- Account status
Hybrid AD Properties
These properties are available for users synchronized from on-premises Active Directory:
OnPremisesSyncEnabledOnPremisesLastSyncDateTimeOnPremisesSamAccountNameOnPremisesUserPrincipalNameImmutableIdProxyAddresses
Migrating to Microsoft Graph
The AzureAD module is being deprecated. Consider migrating to Microsoft Graph PowerShell for new scripts. See the Microsoft Graph PowerShell guide for equivalent commands.