Building labs in a hurry sometimes can bite you with recent changes in Office 365 connections. I just got hit with a problem with PowerShell module for Azure Active Directory not connecting:
1 2 3 4 5 6 7 8 |
PS C:\Users\Administrator> Connect-MsolService Connect-MsolService : Authentication Error: Unexpected authentication failure. At line:1 char:1 + Connect-MsolService + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [Connect-MsolService], Exception + FullyQualifiedErrorId : System.Exception,Microsoft.Online.Administration.Automation.ConnectMsolService |
The problem relates to the connection type from a very unpatched (on purpose) Windows 2016 lab server for developing a Powershell script against Azure AD. While working out the authentication errors I noticed a TLS issue. At this point of time there has been a major change by Microsoft from TLS 1.1 to 1.2 which stopped the Auth Process to connect using command Connect-msolservice.
Running the following command fix this issue:
1 |
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" /v SchUseStrongCrypto /t REG_DWORD /d 1 /f |
This force .net 4.x or higher to use TLS 1.2 for connections. Powershell Connections to Azure AD now restored.
I hope this help others!
I ran into this problem and am so glad you wrote up a nice and easy guide to fixing it. It tested perfectly without a restart to resolve my connectivity issues! Thanks!
I was having the exact same issue. I was throwing the error when I ran my script from the Powershell ISE. I used this workaround and it did the trick…thanks!
Thanks a lot. This is awesome to solve a problem I have been ignoring 🙂
I was having this issue with a central Powershell reporting server I had established. Thank you for finding this out!
1000X Thanks 🙂
Very thanks :))
Hi, this works like a charm!, I had to restart the server but it worked!, thank you so much!