TLS 1.2 and PowerShell
To view security protocol that your PowerShell currently uses, use the below command:
[Net.ServicePointManager]::SecurityProtocol
By default, PowerShell doesn't use TLS 1.2. This causes some problems if you use PowerShell a lot to work with Dynamics 365 and other popular SaaS applications, due to more and more applications are now forcing TLS 1.2 for incoming connections.
Taking Dynamics 365 as an example, you may now keep getting the error message "More then one org was returned, retry with an exact org name" when using Get-CrmConnection PowerShell command. This is due to Dynamics 365 now only accepts TLS 1.2 connections, and your PowerShell is not forcing that.
To work around it, put the below PowerShell command before making the connection:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
Just like doing the same in C# code to force the connection to use TLS 1.2, but this is in PowerShell. The Get-CrmConnection command should now return the connection object rather than the error message, given that the provided org name is correct.
If you don't want to put this as part of the PowerShell code, and would like PowerShell to always use TLS 1.2, then you can put the above code in your Microsoft.PowerShell_profile.ps1 and/or Microsoft.PowerShellISE_profile.ps1.
[Net.ServicePointManager]::SecurityProtocol
By default, PowerShell doesn't use TLS 1.2. This causes some problems if you use PowerShell a lot to work with Dynamics 365 and other popular SaaS applications, due to more and more applications are now forcing TLS 1.2 for incoming connections.
Taking Dynamics 365 as an example, you may now keep getting the error message "More then one org was returned, retry with an exact org name" when using Get-CrmConnection PowerShell command. This is due to Dynamics 365 now only accepts TLS 1.2 connections, and your PowerShell is not forcing that.
To work around it, put the below PowerShell command before making the connection:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
Just like doing the same in C# code to force the connection to use TLS 1.2, but this is in PowerShell. The Get-CrmConnection command should now return the connection object rather than the error message, given that the provided org name is correct.
If you don't want to put this as part of the PowerShell code, and would like PowerShell to always use TLS 1.2, then you can put the above code in your Microsoft.PowerShell_profile.ps1 and/or Microsoft.PowerShellISE_profile.ps1.
NliavecOimze-1985 Matt Mueller https://wakelet.com/wake/AveCP3rRYwEGfJBjpM2AO
ReplyDeletedephopilsblos
agos0cu-pa Renee Davis Adobe Media Encoder
ReplyDeleteESET NOD32 Internet Security
UnHackMe
recasedovs