How to Bulk Update Mfa Phone Auth Method Using Powershell

Intro

If you want to update Phone Auth method for a Single user, you can use Authentication Methods option on Azure Portal under user section. However, there is NO easy way to update Phone Auth Method in Bulk for all the users in the tenant Azure Portal. Documentation: Manage authentication methods for Azure AD Multi-Factor Authentication - Azure Active Directory | Microsoft Docs only shares a command to update phone method for single user. However, customer wanted to update the MFA Phone Auth Method using a CSV file using UPN and phone number.

Install and Import Modules:

Install-Module MgGraph

Update MFA Phone Auth Method in Bulk

Below is the Script and CSV format that needs to be used to update MFA Phone Method in Bulk.

CSV Format

"UPN","Number"
[email protected],+91 XXXXXXXXXX
[email protected],+91 XXXXXXXXXX
[email protected],+91 XXXXXXXXXX

Script with readable comments:

Connect-MgGraph -Scopes UserAuthenticationMethod.ReadWrite.All
Select-MgProfile -Name beta
Write-host "++++++++++ Updating MFA Authentication Methods for all users ++++++++++" -ForegroundColor Black -BackgroundColor White
$csv = Import-Csv -Path C:\Users\hamathar\Desktop\AuthMethods.csv
Foreach ($line in $csv)
{
    $UserInfo = Get-MgUserAuthenticationPhoneMethod -UserId $line.UPN | Select-Object *Phonenumber 
    If ($UserInfo -ne $null)
{
        Write-host "User "$line.UPN" already has MFA Method registered as $UserInfo" -ForegroundColor Red 
}
else
{
      New-MgUserAuthenticationPhoneMethod -UserId $line.UPN -phoneType "mobile" -phoneNumber $line.Number | Out-Null
      Write-host "Updated MFA Auth Method for user "$line.UPN" with value "$Line.Number"" -ForegroundColor Green 
}
}
Write-host "++++++++++ MFA Authentication Phone Method has been updated ++++++++++" -ForegroundColor Black -BackgroundColor White

Script with sample output

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest