Skip to content

Instantly share code, notes, and snippets.

@dansmith65
Created August 23, 2022 01:33
Show Gist options
  • Save dansmith65/1691f9f0145194ce067323a5787b71bd to your computer and use it in GitHub Desktop.
Save dansmith65/1691f9f0145194ce067323a5787b71bd to your computer and use it in GitHub Desktop.
Install version 2 of AWS CLI via PowerShell
# https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
$dlurl = "https://awscli.amazonaws.com/AWSCLIV2.msi"
$installerPath = Join-Path $env:TEMP (Split-Path $dlurl -Leaf)
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $dlurl -OutFile $installerPath
Start-Process -FilePath msiexec -Args "/i $installerPath /passive" -Verb RunAs -Wait
Remove-Item $installerPath
$env:Path += ";C:\Program Files\Amazon\AWSCLIV2"
@sblack4
Copy link

sblack4 commented May 10, 2024

Google sent me here. This failed with error

Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ Invoke-WebRequest $dlurl -OutFile $installerPath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I added [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 and now it works: https://gist.github.com/sblack4/196e4bb143ce68726d85b545b9c4886d

@hegyre
Copy link

hegyre commented Jan 29, 2025

No need to manually download the msi. msiexec can directly install from an https url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment