I need to update listItem in a SharePoint site ( SharePoint2016). Actually there is a proxy that cant allow me to access. the proxy is with login and password.

first I tried the window webClient :

    [System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Try {

   Connect-PnPOnline -Url https://xxxx -UseWebLogin
   Write-Host "Connected" -ForegroundColor Green
   write-host "Site: "+$Site.Title;
    write-host "web: " + $web.Title
    write-host "web: " + $web.id
    Write-Host "Connected" -ForegroundColor Green

catch {
    Write-Host "Not able to connect" -ForegroundColor Red

The error is :

Get-PnPSite : Cannot contact site at the specified URL https://xxxx Au caractère Ligne:5 : 10 + $Site=Get-PnPSite .....

the other way is using the Invoke-webrequest:

#proxy supports NTLM/AD authentication $Wcl = new-object System.Net.WebClient $Wcl.Headers.Add(“user-agent”, “PowerShell
 Script”) $Wcl.Proxy.Credentials =

$Test=Invoke-WebRequest https://xxx
Connect-PnPOnline -Url https://xxx -UseWebLogin
   Write-Host "Connected" -ForegroundColor Green


Get-PnPSite : Cannot contact site at the specified URL Au caractère Ligne:1 : 7 + $Site=Get-PnPSite + ~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Get-PnPSite], ClientRequestException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Site.GetSite

Any idea !


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.