Microsoft 365 – Disable MFA on admin account using PowerShell when locked out

The phone-number associated with the admin account was no longer available so the client couldn’t access the admin portal of Microsoft 365 as the following message popped-up:

“More information required – Your organisation needs more information to keep your account secure”

And there was NO way to get passed that. Total lock-out. So, fire up PowerShell on a Windows machine (PS on a Mac does not work with MSOnline) and copy/paste the following lines to disable MFA and get asked to enter a new phone number! Please change the admin email and password to yours.

Set-ExecutionPolicy RemoteSigned
Install-Module PowershellGet -Force
Install-Module -Name ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement

$secpasswd = ConvertTo-SecureString -String 'SuperSecretPassword' -AsPlainText -Force
$o365cred = New-Object System.Management.Automation.PSCredential ("adminemail@address.com", $secpasswd)
Connect-ExchangeOnline -Credential $o365cred -ShowBanner:$false

Install-Module MSOnline
Import-Module MSOnline
Connect-MsolService -Credential $o365cred

Get-MsolUser -UserPrincipalName adminemail@address.com | Set-MsolUser -StrongAuthenticationMethods @()