Private/Install/Save-PWSHYBKPIVDownloadFile.ps1
|
function Save-PWSHYBKPIVDownloadFile { <# .SYNOPSIS Downloads a file to a local path over HTTPS with TLS 1.2 enforced. .DESCRIPTION Windows PowerShell 5.1 does not default to TLS 1.2, which developers.yubico.com requires; this forces it on the current session's ServicePointManager before calling Invoke-WebRequest. Extracted into its own function so the download step can be unit tested with a mock instead of making a real network call. .PARAMETER Uri The URL to download. .PARAMETER OutFile The local path to save the downloaded file to. .EXAMPLE Save-PWSHYBKPIVDownloadFile -Uri $url -OutFile $tempMsiPath #> [CmdletBinding()] param( [Parameter(Mandatory)] [string] $Uri, [Parameter(Mandatory)] [string] $OutFile ) [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -Uri $Uri -OutFile $OutFile -UseBasicParsing } |