【发布时间】:2022-07-12 22:39:34
【问题描述】:
我正在尝试通过 PowerShell 安装 Visual Studio,在本地计算机上运行良好,但在我们的 AWS Windows Server 2012R2 上运行它时不断出现错误。我在下面附上了我的代码和错误。谢谢
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$这里=密码 $software = "Microsoft Visual Studio 安装程序"; $installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall* | Where { $_.DisplayName -eq $software }) -ne $null
#如果之前没有安装过VSCode,则会下载需要的文件并安装。
如果(-未安装)
{
Write-Host "'$software' 没有安装。";
wget https://aka.ms/vs/17/release/vs_community.exe -outfile “vs.exe”
.\vs.exe install --quiet --norestart
} #如果之前安装过 VSCode,它将尝试将其更新到较新的版本(如果有)。
#如果没有可用的更新,它将什么都不做。
其他
{
Write-Host "'$software' 已安装。"
if (Test-Path -Path $here\vs.exe)
{
.\vs.exe 更新 --quiet --norestart
}
否则 {
wget https://aka.ms/vs/17/release/vs_community.exe -outfile "vs.exe"
.\vs.exe 更新 --quiet --norestart
}
}
【问题讨论】:
-
不要粘贴截图。而是复制并粘贴错误。
-
请格式化发布的脚本。
-
请问我该怎么做@jarmod
标签: windows amazon-web-services powershell visual-studio-code