Authentication to Office 365If you are using a Federation Server for the authorization to Office 365 tenant of Microsoft and this Federation Server is not supporting TLS 1.1 encryption anymore you can run into an error if you are connecting in a PowerShell script against this tenant. This will happened special in scripts when you are not using the login prompt getting from web browser. You are often send the credentials by using the parameter -Credential as a secure string.
IssueDepending of the .NET Framework you are using on your client the default version of the encryption is TLS 1.1. The PowerShell bash is not using TLS 1.2 in this case and this is the reason why the authentication is failing:
SolutionYou have to define the TLS 1.2 encryption as default for this PowerShell session. This must be done in the beginning of each script. Please do this:
- My GitLab: Force TLS 1.2 encryption in PowerShell scripts
- Perficient Blog: TLS 1.2 and .NET Support: How to Avoid Connection Errors
- StackOverflow: Unexpected error occurred running a simple unauthorized Rest query