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:
1Connect-MsolService : Authentication Error: Unexpected authentication failure
2 Answers
I had a similar issue. I ran the PowerShell below:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Connect-MsolService 3You 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.