I have a Windows Server 2012 R2 server that has all protocols other than TLS 1.2 disabled. When I try to use powershell commandlets for Application Insights it reaches out to obtain nuget packages and fails.
I created a script that sets the protocol explicitly before running the command but it seems the commandlet was written targeting .NET 4.5 or lower and is using the default protocol selection scheme which limits it to TLS 1.0.
Import-Module 'C:\Program Files\Microsoft Application Insights\Status Monitor\PowerShell\Microsoft.Diagnostics.Agent.StatusMonitor.PowerShell.dll'
#fails on server that requires TLS 1.2
Invoke-WebRequest "https://packages.nuget.org/api/v2"
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
#works on server that requires TLS 1.2
Invoke-WebRequest "https://packages.nuget.org/api/v2"
#fails under both conditions
Get-ApplicationInsightsMonitoringStatus
How can you get the App Insights powershell commandlets to work on a server with only TLS 1.2 enabled?