Get-MsOUsers-Html
MSOnline: HTML report of Azure AD users
#Requires -Version 5.1
[CmdletBinding()]
Param(
[switch]$HasErrorsOnly,
[switch]$OnlyDeletedUsers,
[switch]$OnlyUnlicensedUsers,
[switch]$LicenseReconciliationNeededOnly,
[ValidateSet('All','EnabledOnly','DisabledOnly')]
[string]$Filter = 'All',
[guid]$TenantId
)
Process {
try {
[hashtable]$getArgs = @{'ErrorAction' = 'Stop'; 'TenantId' = $TenantId}
if ($HasErrorsOnly) { $getArgs.Add('HasErrorsOnly', $true) }
if ($OnlyDeletedUsers) { $getArgs.Add('ReturnDeletedUsers', $true) }
if ($OnlyUnlicensedUsers) { $getArgs.Add('UnlicensedUsersOnly', $true) }
if ($LicenseReconciliationNeededOnly) { $getArgs.Add('LicenseReconciliationNeededOnly', $true) }
if ($Filter -ne 'All') { $getArgs.Add('EnabledFilter', $Filter) }
$result = Get-MsolUser @getArgs | Select-Object DisplayName, UserPrincipalName, Department, Title, ObjectId, IsLicensed
if ($null -eq $result -or $result.Count -eq 0) { Write-Output "No users found"; return }
Write-Output ($result | ConvertTo-Html -Fragment)
}
catch { throw }
}Off
Only users with validation errors
Off
Only users in recycle bin
Off
Only users without a license
Off
Only users needing license reconciliation
Filter by enablement status
Unique ID of the tenant