我想在 VSTS 上以管理员身份运行 cmd。
实际上,我正在尝试在 VSTS 托管代理上安装带有 Chocolatey 工具管理器的 git-tfs,因此我在 VSTS 命令行任务上运行以下命令:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(' https://chocolatey .org/install.ps1 '))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
或者,
另外,VSTS 还提供了 Chocolatey 任务进行安装,您可以在屏幕截图中看到这一点:
上述两种方法都会给出相同的错误: