代码之家  ›  专栏  ›  技术社区  ›  sajis997

Azure DevOps管道中的Powershell脚本无法访问internet

  •  0
  • sajis997  · 技术社区  · 5 年前

    已配置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"
    

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

    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管理员比Azure DevOps构建代理拥有更多的访问权限。但它至少应该能够访问互联网。

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

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

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

    通过在命令中添加“-Scope CurrentUser”。 您还可以尝试使用提升的权限运行Windows PowerShell会话(以管理员身份运行)。

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

    0 回复  |  直到 5 年前