Error connecting to Microsoft365 using MFA: The sign-in name or password does not match one in the Microsoft account system

If you have received any of these errors lately trying to connect via Multi-Factor Authentication (MFA) to your Microsoft365 tenant using PowerShell, the resolution may be that you need to revise your login script.

Click each image to open in a new window.

Connect-PnPonline: root element is missing

Connect-PnPonline: The sign-in name or password does not match one in the Microsoft account system.

Connect-SPOservice: The sign-in name or password does not match one in the Microsoft account system.

Simply put, the resolution we’ve found is to use the -UseWebLogin parameter with both cmdlets Connect-PnPOnline and Connect-SPOService

By using -UseWebLogin instead of -Credentials it gives a pop up for your login info and lets you access the system, particularly if you are using Multi-factor Authentication (MFA). Connect-SPOService is similar, but you just take out the -Credentials altogether and it will do the same.

Old way

$url = "https://<tenantname>.sharepoint.com/"
$credentials = Get-Credential
Connect-PnPOnline -Url $url -Credentials $credentials

New way

$url = "https://<tenantname>.sharepoint.com/"
Connect-PnPOnline -Url $url -UseWebLogin

 

Many thanks to my colleague Josh Nissen who figured this out and also contributed to the content of this article.

 

Digiprove sealCopyright secured by Digiprove © 2020-2021 Douglas Spicer