Force PowerShell to Use TLS 1.2

By default, some versions of Windows force PowerShell to use TLS 1.0 for commands like Invoke-WebRequest. Since Automox requires TLS 1.2 for secure communication over Powershell, attempting to download files or execute commands without configuring this may fail.

Solution (For singular Powershell Session)

  1. Open PowerShell as an Administrator (32-bit or 64-bit).
  2. Run the following command:

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  3. The current Powershell session or script should now run at 1.2

Solution (Permanent on device)

Follow these steps to configure PowerShell to use TLS 1.2:

  1. Open PowerShell as an Administrator (32-bit or 64-bit).
  2. Run the following script:
$scriptBlock = { 
    $registryPaths = @(
  "HKLM:\SOFTWARE\Microsoft\.NETFramework\v2.0.50727",
  "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319",
  "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727",
  "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319"
)

$values = @{
  "SystemDefaultTlsVersions" = 1
  "SchUseStrongCrypto"       = 1
}

foreach ($path in $registryPaths) {
  if (-not (Test-Path $path)) {
    New-Item -Path $path -Force | Out-Null
  }

  foreach ($name in $values.Keys) {
    New-ItemProperty `
      -Path $path `
      -Name $name `
      -Value $values[$name] `
      -PropertyType DWord `
      -Force | Out-Null
  }
} }

$exitCode = & "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" `
    -ExecutionPolicy Bypass `
    -WindowStyle Hidden `
    -NoProfile `
    -NonInteractive `
    -Command $scriptBlock

Verification

To ensure TLS 1.2 is in use:

  • Run a command requiring Invoke-WebRequest and verify no TLS-related errors occur.

     

    Invoke-Webrequest "https://api.automox.com" -UseBasicParsing

 

Was this article helpful?
0 out of 0 found this helpful