A Microsoft cloud service that enables deployment of Azure services across hybrid and multicloud environments.
Hello palm lbi, You are running the Azure agent onboarding PowerShell script (OnboardingScript.ps1) on a Windows Server 2012 R2 machine. You have already verified that TLS 1.0 / 1.1 / 1.2 are enabled at the OS level, and the target Azure URL is reachable in a browser, but the script still fails.
The issue you are getting might be the reason below.
- PowerShell uses .NET, not the OS TLS settings directly: On Windows Server 2012 R2, .NET defaults to TLS 1.0, even if TLS 1.2 is enabled in the OS.
- Azure onboarding endpoints reject TLS 1.0 / 1.1: When PowerShell attempts the request using an older protocol, the server drops the connection during the TLS handshake, resulting in this error.
- The error message is misleading: The message suggests a network issue, but the real cause is TLS protocol negotiation failure, not connectivity.
This behavior is widely documented for Invoke-WebRequest on Server 2012 R2 and PowerShell ≤ 5.1. Invoke-WebRequest (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
To resolve this :
Force TLS 1.2 in the onboarding script (mandatory): Add this line at the very top of OnboardingScript.ps1, before any Invoke‑WebRequest call:
[Net.ServicePointManager]::SecurityProtocol =
[Net.SecurityProtocolType]::Tls12 `
-bor [Net.SecurityProtocolType]::Tls11 `
-bor [Net.SecurityProtocolType]::Tls
This explicitly forces PowerShell to negotiate TLS 1.2 and resolves the issue in most cases.
Verify PowerShell and .NET versions:
Requirements:
- PowerShell 5.1
- .NET Framework 4.6 or higher
Older versions on Server 2012 R2 are known to fail TLS 1.2 connections even when forced.
Hope this helps. and please feel free to reach out if you have any further questions. Thanks