Connect-PnPOnline 不适用于生成代理
Connect-PnPOnline does not work with build agent
脚本中的以下 powershell 片段在本地机器上运行良好:
$SharepointConnection = Connect-PnPOnline -Url $ConfigInfo.AProcessDef.ASharePointUrl.ToString().Trim() -Credential $SharepointCredential -ReturnConnection -Verbose -ErrorAction Stop
但是当 运行 Azure DevOps 构建代理(代理服务器后面的自托管代理)在构建 VM 机器上执行完全相同的片段时,它失败了。构建机器在代理后面并且已经配置好了。我已经检查了 InvokeWebRequest 以访问组织的本地 Intranet 和 Internet,并且运行良好。我在 Connect-PnPOnline 中遇到以下异常:
System.Net.WebException The remote name could not be resolved:
我登录到 vm 机器,执行代码段没有任何错误。我可以连接到 domainname.sharepoint.com。
感谢一些提示来解决这个问题。
问题已通过 powershell 脚本中的以下代码片段得到解决:
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($ConfigInfo.Proxy.ToString().Trim())
[system.net.webrequest]::defaultwebproxy.credentials =
[System.Net.CredentialCache]::默认网络凭证
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $真
脚本中的以下 powershell 片段在本地机器上运行良好:
$SharepointConnection = Connect-PnPOnline -Url $ConfigInfo.AProcessDef.ASharePointUrl.ToString().Trim() -Credential $SharepointCredential -ReturnConnection -Verbose -ErrorAction Stop
但是当 运行 Azure DevOps 构建代理(代理服务器后面的自托管代理)在构建 VM 机器上执行完全相同的片段时,它失败了。构建机器在代理后面并且已经配置好了。我已经检查了 InvokeWebRequest 以访问组织的本地 Intranet 和 Internet,并且运行良好。我在 Connect-PnPOnline 中遇到以下异常:
System.Net.WebException The remote name could not be resolved:
我登录到 vm 机器,执行代码段没有任何错误。我可以连接到 domainname.sharepoint.com。
感谢一些提示来解决这个问题。
问题已通过 powershell 脚本中的以下代码片段得到解决: [system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($ConfigInfo.Proxy.ToString().Trim()) [system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::默认网络凭证 [system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $真