Share via

Connect-pnponline: Timeout with certificate based authentication from remote server

von Lachner, Matthias 25 Reputation points
2025-04-22T10:46:24.11+00:00

I uploaded a Certificate which has a private key on my machine which runs the script. It worked out so far, but now it runs into a timeout when I try to execute it remotely (From Server X on the machine where it worked out). My Script currently looks like this:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

pwsh{
import-module PnP.PowerShell
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://myProxy:8080')
#Proxy doesnt need authentication
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

$PWEncoded = "MyPW" |ConvertTo-SecureString -AsPlainText -force

Connect-PnPOnline "https://.sharepoint.com/sites/MySite/"  -ClientId "MyClientID" -Tenant "MyTenant.onmicrosoft.com" -CertificatePath "\\MyServer\D$\SPO\MyCert.pfx" -CertificatePassword $PWEncoded  -Verbose

Add-PnPFile -Path "C:\Temp\MyFile.txt" -newFileName "MyName"  -Folder "MyFolder/Test"

}

When I run this Script remotely from Server X on the very same machine where it was working locally, I get a timeout while connecting with my client ID:

VERBOSE: Cmdlet execution started for Connect-PnPOnline [...] -Verbose VERBOSE: Connecting using Entra ID App-Only using a certificate[0m VERBOSE: Using ClientID MyClientID pwsh.exe : Connect-PnPOnline: In Zeile:1 Zeichen:1

  • pwsh.exe "C:\Users\Me\Desktop\Scripts\pwshTest.ps1"
  • + CategoryInfo : NotSpecified: (Connect-PnPOnline: [:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError

[Connect-PnPOnline "https://MyTenant.sharepoint.com/sites/ Request to the endpoint timed out.

I also tried pwsh.exe $ScriptPath but it ended the same way.

Microsoft 365 and Office | SharePoint | Development
0 comments No comments

1 answer

Sort by: Most helpful
  1. Leppin, Jochen 0 Reputation points
    2026-01-07T20:44:06.3166667+00:00

    Check out this page https://pnp.github.io/powershell/articles/configuration.html#disable-or-enable-version-checks For me it finally fixed the issue. Seems to me that Microsoft had issues to "phone home" (firewall issue?). ;)

    Quick guide on Linux:

    1. pwsh
    2. nano $PROFILE
    3. Add those lines to the $PROFILE file:
      $env:PNPPOWERSHELL_UPDATECHECK = "off"
      $env:PNPPOWERSHELL_DISABLETELEMETRY = "true"
    4. Save and close nano
    5. To apply the changes immediately to your current session, run:
      . $PROFILE
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.