Entra / Microsoft 365 · Users & guests
Report authentication methods
A report of the authentication methods for Azure AD licensed accounts.
Connect & set up
Run these once per session. All scopes are read-only unless the script makes changes.
Connect-MgGraph -Scopes UserAuthenticationMethod.Read.All, Directory.Read.All, User.Read.All
Run it
The main script. Copy it, or download the .ps1 and run it from your console.
Connect-MgGraph -Scopes UserAuthenticationMethod.Read.All, Directory.Read.All, User.Read.AllSelect-MgProfile BetaWrite-Host "Finding licensed Azure AD accounts"[array]$Users = Get-MgUser -Filter "assignedLicenses/`$count ne 0 and userType eq 'Member'" -ConsistencyLevel eventual -CountVariable Records -AllIf (!($Users)) { Write-Host "No licensed users found in Azure AD... exiting!"; break }$i = 0$Report = [System.Collections.Generic.List[Object]]::new()ForEach ($User in $Users) {$i++Write-Host ("Processing user {0} {1}/{2}." -f $User.DisplayName, $i, $Users.Count)$AuthMethods = Get-MgUserAuthenticationMethod -UserId $User.IdForEach ($AuthMethod in $AuthMethods) {$P1 = $Null; $P2 = $Null$Method = $AuthMethod.AdditionalProperties['@odata.type']Switch ($Method) {"#microsoft.graph.passwordAuthenticationMethod" {$DisplayMethod = "Password"$P1 = "Traditional password"}"#microsoft.graph.microsoftAuthenticatorAuthenticationMethod" {$DisplayMethod = "Authenticator"$P1 = $AuthMethod.AdditionalProperties['displayName']$P2 = $AuthMethod.AdditionalProperties['deviceTag'] + ": " + $AuthMethod.AdditionalProperties['clientAppName']}"#microsoft.graph.fido2AuthenticationMethod" {$DisplayMethod = "Fido 2 Key"$P1 = $AuthMethod.AdditionalProperties['displayName']$P2 = Get-Date($AuthMethod.AdditionalProperties['creationDateTime']) -format g}"#microsoft.graph.phoneAuthenticationMethod" {$DisplayMethod = "Phone"$P1 = "Number: " + $AuthMethod.AdditionalProperties['phoneNumber']$P2 = "Type: " + $AuthMethod.AdditionalProperties['phoneType']}"#microsoft.graph.emailAuthenticationMethod" {$DisplayMethod = "Email"$P1 = "Address: " + $AuthMethod.AdditionalProperties['emailAddress']}"#microsoft.graph.passwordlessMicrosoftAuthenticatorAuthenticationMethod" {$DisplayMethod = "Passwordless"$P1 = $AuthMethod.AdditionalProperties['displayName']$P2 = Get-Date($AuthMethod.AdditionalProperties['creationDateTime']) -format g}"Default" {$DisplayMethod = $Method}}$ReportLine = [PSCustomObject] @{User = $User.DisplayNameMethod = $DisplayMethodId = $AuthMethod.IdP1 = $P1P2 = $P2UserId = $User.Id }$Report.Add($ReportLine)} #End ForEach Authentication Method} #End ForEach User$Report = $Report | Sort-Object UserWrite-Host ""Write-Host "Authentication Methods found"Write-Host "----------------------------"Write-Host ""$Report | Group-Object Method | Sort-Object Count -Descending | Select Name, Count$Report | Out-GridView
Attribution
Author
Office365itpros