Connect-pnponline: Timeout with certificate based authentication from remote server
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.