If you’ve recently deployed MFA (Multi-Factor Authentication) in Office365/ Azure you may find that there is no easy way to report who has MFA enabled, and more importantly, which of your administrators don’t have MFA enabled. I ran across a problem that I needed to solve so I turned to Powershell for my solution. Therefore, I created a script to get MFA status using Powershell.

Here we will assume you have the correct permissions to access the MSOL service and the email address and userprincipalname are the same

Get MFA Status Using Powershell

Function Get-AzureMFAStatus { <# .Synopsis This will get the Multi-factor authentication status of your users and determine which of them or not are admins. For updated help and examples refer to -Online version. .DESCRIPTION This will get the Multi-factor authentication status of your users and determine which of them or not are admins. For updated help and examples refer to -Online version. .NOTES Name: Get-AzureMFAStatus Author: theSysadminChannel Version: 1.0 DateCreated: 2019-Feb-08 .LINK https://thesysadminchannel.com/get-mfa-status-for-azure-office365-users-using-powershell - #> [CmdletBinding()] param( [Parameter( Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true )] [string[]] $UserPrincipalName, [int] $MaxResults = 2000, [bool] $isLicensed = $true, [switch] $SkipAdminCheck ) BEGIN { if (-not $SkipAdminCheck) { $AdminUsers = Get-MsolRole -ErrorAction Stop | foreach {Get-MsolRoleMember -RoleObjectId $_.ObjectID} | Where-Object {$_.EmailAddress -ne $null} | Select EmailAddress -Unique | Sort-Object EmailAddress } } PROCESS { if ($UserPrincipalName) { foreach ($User in $UserPrincipalName) { try { Get-MsolUser -UserPrincipalName $User -ErrorAction Stop | select DisplayName, UserPrincipalName, ` @{Name = 'isAdmin'; Expression = {if ($SkipAdminCheck) {Write-Output "-"} else {if ($AdminUsers -match $_.UserPrincipalName) {Write-Output $true} else {Write-Output $false}}}}, ` @{Name = 'MFAEnabled'; Expression={if ($_.StrongAuthenticationMethods) {Write-Output $true} else {Write-Output $false}}} } catch { $Object = [pscustomobject]@{ DisplayName = '_NotSynced' UserPrincipalName = $User isAdmin = '-' MFAEnabled = '-' } Write-Output $Object } } } else { $AllUsers = Get-MsolUser -MaxResults $MaxResults | Where-Object {$_.IsLicensed -eq $isLicensed} | select DisplayName, UserPrincipalName, ` @{Name = 'isAdmin'; Expression = {if ($SkipAdminCheck) {Write-Output "-"} else {if ($AdminUsers -match $_.UserPrincipalName) {Write-Output $true} else {Write-Output $false}}}}, ` @{Name = 'MFAEnabled'; Expression={if ($_.StrongAuthenticationMethods) {Write-Output $true} else {Write-Output $false}}} Write-Output $AllUsers | Sort-Object isAdmin, MFAEnabled -Descending } } END {} }

So that’s it. That’s how you get MFA status for Office365 / Azure for your domain. Hopefully you found this useful and if you did, don’t forget to check out our Youtube channel at @theSysadminChannel