I'm trying to install visual studio through PowerShell, works fine on local computer, but I keep getting errors when I run it on our AWS windows server 2012R2. I've attached my code and error below. Thank you
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$here = pwd
$software = "Microsoft Visual Studio Installer";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null
#If VSCode was not installed before, it will be download required files and install it.
If(-Not $installed)
{
Write-Host "'$software' is NOT installed.";
wget https://aka.ms/vs/17/release/vs_community.exe -outfile “vs.exe”
.\vs.exe install --quiet --norestart
}
#If VSCode was installed before, it will try to update it to the newer version, if available.
#If no updates available, it will do nothing.
else
{
Write-Host "'$software' is installed."
if ( Test-Path -Path $here\vs.exe )
{
.\vs.exe update --quiet --norestart
}
else {
wget https://aka.ms/vs/17/release/vs_community.exe -outfile "vs.exe"
.\vs.exe update --quiet --norestart
}
}
You have used the option -outfile vs.exe
but this is not how you tell wget
to rename the downloaded file. What this actually does is the following:
vs_community.exe
(because that's the filename in the original URL)utfile
vs.exe
parameterThe wget option to direct the downloaded content to a named file is actually -O
, not -outfile
(which is the equivalent of -o utfile
, which writes the log to utfile
).
To specify the correct output filename, use:
-O vs.exe
Or simply execute wget https://aka.ms/vs/17/release/vs_community.exe
and then execute the downloaded file, which is named vs_community.exe
.
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.