I am trying to check if aws cli is installed already, and install it if not present, I can't find any source on how to install it through PowerShell script
function prereq {
if ((Get-Command aws -ErrorAction SilentlyContinue) -eq $null) {
Write-Host "Unable to find aws.exe in your PATH."
} else {
# Download from this link https://awscli.amazonaws.com/AWSCLIV2.msi
# Install the AWSCLIV2.msi
# print aws cli version "aws --version"
}
}
prereq
After some research I was able to find a solution:
function prereq {
if ((Get-Command aws -ErrorAction SilentlyContinue) -eq $null) {
Write-Host "Unable to find aws.exe in your PATH."
} else {
$command = "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
Invoke-Expression $command
Invoke-WebRequest -Uri "https://awscli.amazonaws.com/AWSCLIV2.msi" -Outfile C:\AWSCLIV2.msi
$arguments = "/i `"C:\AWSCLIV2.msi`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
}
}
prereq
If you are using PowerShell 7, you can easily install it using the Windows Project Manager(WINGET). Use following command >
winget install --id "Amazon.AWSCLI"
You can also look for it and other AWS utilites using the following command >
winget search --name "aws"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.