Ammar Bin Yahya
Ammar Bin Yahya

Reputation: 21

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

Upvotes: 2

Views: 15251

Answers (2)

charlesned
charlesned

Reputation: 31

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

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Connect-MsolService

Upvotes: 3

Carl Zhao
Carl Zhao

Reputation: 9549

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.

Upvotes: 0

Related Questions