【问题标题】:Connect-PnPOnline does not work with build agentConnect-PnPOnline 不适用于构建代理
【发布时间】:2020-03-18 19:11:57
【问题描述】:

脚本中的以下 powershell sn-p 在本地机器上运行良好:

$SharepointConnection = Connect-PnPOnline -Url $ConfigInfo.AProcessDef.ASharePointUrl.ToString().Trim() -Credential $SharepointCredential -ReturnConnection -Verbose -ErrorAction Stop

但是,当 Azure DevOps 构建代理(代理服务器后的自托管代理)在构建 VM 机器上运行相同的 sn-p 时,它会失败。构建机器位于代理后面,并且已经配置。我已经检查过 InvokeWebRequest 以访问组织的本地 Intranet 和 Internet,它运行良好。 Connect-PnPOnline 出现以下异常:

 System.Net.WebException The remote name could not be resolved:

我登录了 vm 机器,执行了 sn-p 没有任何错误。我可以连接到 domainname.sharepoint.com。

感谢一些提示来解决这个问题。

【问题讨论】:

  • 错误`System.Net.WebException The remote name could not besolved:`通常表示代理或DNS有问题。如果在本地ping urlping xxx.com 并使用self-agent 调用命令ping some-domain-that-doesnt-exist.com 的命令行任务,结果如何?有什么区别吗?

标签: azure-devops sharepoint-online


【解决方案1】:

已通过 powershell 脚本中的以下 sn-p 解决了该问题: [system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($ConfigInfo.Proxy.ToString().Trim()) [system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials [system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-25
  • 2019-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多