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/

enter image description here

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>
Share:
6,794

Related videos on Youtube

ExceptionLimeCat
Author by

ExceptionLimeCat

I am a C# &amp; JavaScript developer currently peddling in the SharePoint space.

Updated on September 18, 2022

Comments

  • ExceptionLimeCat
    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

    https://docs.microsoft.com/en-us/azure/active-directory/authentication/howto-sspr-authenticationdata#set-and-read-authentication-data-using-powershell

    enter image description here

  • ExceptionLimeCat
    ExceptionLimeCat over 4 years
    were 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
    ExceptionLimeCat over 4 years
    Were 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
    Architect Jamie over 4 years
    Yes. 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
    Kathy Cooper over 4 years
    After installing MSOnline Module, you need to import MSOnline cmdlets using below cmd-let Import-Module Msonline
  • ExceptionLimeCat
    ExceptionLimeCat over 4 years
    I 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
    ExceptionLimeCat over 4 years
    I am wondering if the StrongAuthenticationUserDetails property is still supported.