1

已配置 Azure VM 预配和代理设置。当我们远程登录到VM机器并插入powershell命令时,如下所示:

Find-Module dockeraccesshelper

我们得到回应:

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
0.0.3      dockeraccesshelper                  PSGallery            Allow a user account to access the docker engine...

所以很明显,从 VM 机器中的管理 Powershell 命令行,我可以在 powershell 存储库中查询模块。为了进一步确认,我发出了以下命令:

Get-ItemProperty -Path "Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

我可以看到列出的代理服务器。我还可以看到环境变量列表下列出的代理服务器。

但是,如果我尝试从 Azure Devops Pipeline 在 VM 上执行 powershell 脚本文件,则会收到以下错误:

WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
WARNING: Unable to download the list of available providers. Check your internet connection.
##[error]PackageManagement\Get-Package : No match was found for the specified search criteria and module names 'VSSetup'.

据了解,VM admin 比 Azure DevOps Build Agent 拥有更多的访问权限。但它至少应该能够访问互联网。

让我详细说明一下 powershell 脚本在做什么:

  1. 从 ps 库安装一些 powershell 模块。

如果我将以下命令作为内联命令运行,我会从管道中获得以下响应:

Log on to the computer with an account that has Administrator rights, and then try again, or install

'C:\windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules' 通过将“-Scope CurrentUser”添加到您的命令。您还可以尝试使用提升的权限运行 Windows PowerShell 会话(以管理员身份运行)。

因此,构建代理必须以管理员身份具有提升的访问权限才能安装/更新模块,这也是显而易见的。关于如何做的任何提示?

4

0 回答 0