1

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
   $Site=Get-PnPSite
   write-host "Site: "+$Site.Title;
    $web=Get-PnPWeb
    write-host "web: " + $web.Title
    write-host "web: " + $web.id
    Write-Host "Connected" -ForegroundColor Green

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

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 =
[System.Net.CredentialCache]::DefaultNetworkCredentials

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

error:

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 !

0

Your Answer

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