Link to home
Start Free TrialLog in
Avatar of Dave Messman
Dave MessmanFlag for United States of America

asked on

Powershell command to find 2FA status on Office365

My powershell skills are weak.  I'm looking for a command I can use to export the two factor authentication status of each user in my organization.  

I'm hoping to get two columns.  One column is the mailbox name and the other column is the 2FA status (disabled, enabled, or enforced).  

I found this page which talks about a way to get the status for a single user:
http://www.virtualizationadmin.com/kbase/VirtualizationTips/ServerVirtualization/MicrosoftHyper-VR2Tips/InstallationDeployment/how-check-mfa-status-office-365-user.html


But this doesn't work for me when I input a proper UPN:
$ThisUSer = Get-msoluser -UserPrincipalName "UserPrincipalName" | Select-Object -ExpandProperty StrongAuthenticationRequirements
$ThisUser.State
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

$upn = "user@example.com"
$ThisUSer = Get-msoluser -UserPrincipalName $upn | Select-Object -ExpandProperty StrongAuthenticationRequirements
    if ($ThisUser -eq $null) {
    $ThisUser = "Not Enabled"
    $thisUser
    }
else {
$ThisUSer.state
}

Open in new window

Avatar of Dave Messman

ASKER

@DavidJohnson - we're close.  

What I'd like is a script that will run through every user in the domain (with no input from me) and output two columns into a CSV file.  Column A is username and column B is 2FA status.

That's what I'm hoping to get.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of alohadin
alohadin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was perfect.  Exactly what I needed.