O365 - Multifactor Auth - Access Authentication Phone via Powershell
6,794
Solution 1
Using below code, you can get a list of MFA enabled users with Authentication Phone number.
$Result=""
$Results=@()
Get-MsolUser -All | where{$_.StrongAuthenticationRequirements.State -ne ""}
| foreach{
$DisplayName=$_.DisplayName
$MFAPhone=$_.StrongAuthenticationUserDetails.PhoneNumber
$Result=@{'DisplayName'=$DisplayName;'MFAPhone'=$MFAPhone}
$Results= New-Object PSObject -Property $Result
$Results | Select-Object DisplayName,MFAPhone | Export-CSV <FilePath> -Append -NoType
}
Else, you can try below PowerShell script.
https://o365reports.com/2019/05/09/export-office-365-users-mfa-status-csv/
Solution 2
A little rewrite of Kathy's answer
Get-MsolUser -All | where{
$_.StrongAuthenticationRequirements.State -ne ""
} | Select DisplayName,@{Name="MFAPhone";Expression={$_.StrongAuthenticationUserDetails.PhoneNumber}} | Export-CSV -NoType <Filename>
Related videos on Youtube
Author by
ExceptionLimeCat
I am a C# & JavaScript developer currently peddling in the SharePoint space.
Updated on September 18, 2022Comments
-
ExceptionLimeCat over 1 year
Is is possible to get/set Authentication Phone via Powershell? I found some old documentation that says this is possible via the old MSOnline module but I cannot find anything in the new AzureAD module.
Old Property: StrongAuthenticationUserDetails
MSOnline Doc
-
ExceptionLimeCat over 4 yearswere you able to run the MSOnline commands? I installed MSOnline module but still received the 'cmdlet not found' message on the commands in that module.
-
ExceptionLimeCat over 4 yearsWere you able to run the MSOnline commands? I installed MSOnline module but still received the 'cmdlet not found' message on the commands in that module.
-
Architect Jamie over 4 yearsYes. If you run
Get-Command -Module MSOnline
do you get any results back?Install-Module -Name MSOnline -Force -AllowClobber
should install the module for you if you get nothing back. See this page docs.microsoft.com/en-us/office365/enterprise/powershell/… for detailed instructions and requirements. -
Kathy Cooper over 4 yearsAfter installing MSOnline Module, you need to import MSOnline cmdlets using below cmd-let
Import-Module Msonline
-
ExceptionLimeCat over 4 yearsI was able to run the MSOnline commands but did not return any data for myself even though I am enrolled in two-factor authentication.
-
ExceptionLimeCat over 4 yearsI am wondering if the StrongAuthenticationUserDetails property is still supported.