Connect-MsolService : Authentication Error: Unexpected authentication failure

I'm trying to connect to azure AD using "App Passwords" as authentication MFA method through powershell script.

this is my script:

$username = '[email protected]' $Password = ConvertTo-SecureString 'MyPassword' -AsPlainText -Force $creds = new-object System.Management.Automation.PSCredential($username, $password) Connect-MsolService -Credential $creds 

But I got this error:

Connect-MsolService : Authentication Error: Unexpected authentication failure

1

2 Answers

I had a similar issue. I ran the PowerShell below:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Connect-MsolService 
3

You cannot put the password in the parameter, because the user logs in using MFA, not the username/password, you should let it pop up the login box and trigger MFA.

There is a similar problem here.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like