【问题标题】:Can Anyone help to figure out what's wrong with my PowerShell script任何人都可以帮助找出我的 PowerShell 脚本有什么问题吗
【发布时间】:2022-07-12 22:39:34
【问题描述】:

我正在尝试通过 PowerShell 安装 Visual Studio,在本地计算机上运行良好,但在我们的 AWS Windows Server 2012R2 上运行它时不断出现错误。我在下面附上了我的代码和错误。谢谢

powershell script

error

[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


【解决方案1】:

您使用了选项-outfile vs.exe,这实际上将文件下载到utfile,因为wget 选项实际上是-O,而不是-outfile

要指定正确的输出文件名,请使用:

-O vs.exe

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-18
    • 2017-04-22
    • 1970-01-01
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多