question

Okeo-0077 avatar image
0 Votes"
Okeo-0077 asked Okeo-0077 answered

Connect-PnPOnline fails - how to debug?

Hi there.

I try to use Connect-PnPOnline to connect to my onprem SharePoint farm and it fails with "An error occurred while sending the request". And I have no idea, what to do.

Details:
I have a SharePoint 2019 farm installed on premise.
On another server (appsrv) installed (xtracted and copied) the pnp.powershell module.
In a powershell window on the appsrv I run this code:
$mycred = Get-Credential MYACCOUNT
Connect-PnPOnline -Url https://my-system.mydom.lcl -Credentials $mycred -Verbose -Debug

The result was the error message
"Connect-PnPOnline : An error occurred while sending the request."

Unfortunately I found no results in the web for this error of this function.
Some search results for the message suggested encryption issues
So I checked TLS:
[Net.ServicePointManager]::SecurityProtocol
and
[System.Net.ServicePointManager]::SecurityProtocol
delivered
Tls, Tls11, Tls12
and
get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto'
get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft.NetFramework\v2.0.50727\' -Name 'SchUseStrongCrypto'

gave "1" as result
Looks good

The URL is accessible via
ping my-system.mydom.lcl
and the SharePoint site pops up when entering the url under the same account.

In the event log there only is this:
Error Message = An error occurred while sending the request.
Fully Qualified Error ID = System.Net.Http.HttpRequestException,PnP.PowerShell.Commands.Base.ConnectOnline

Since the error message doesnt help at all, I tried to debug, but the source code at
https://github.com/pnp/powershell/blob/0120ed972265a949a17b40f8ed3d3dd99efacc61/src/Commands/Base/ConnectOnline.cs
or
https://github.com/pnp/powershell/blob/5580ffd3c29fa97e6fcde0aabe3c05c62072785a/src/Commands/Base/PnPConnection.cs
didnt help.

Trying the same on the SharePoint server itself (with installed powershell module) gave the same

A speciality of the test environmet is no connection to the internet, but that shouldn't matter for use on premise ...


Has anyone a clue, what I'm doing wrong or any hints, where I should have a look at?

thanks in advance

okeo












office-sharepoint-server-development
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AllenXu-MSFT avatar image
0 Votes"
AllenXu-MSFT answered

Hi @Okeo-0077 ,

I couldn't reproduce this issue on my end(the version of my PnP PowerShell module is 3.29.2101.0). Also, I couldn't find any related documentations to this issue. Does this issue happen when connecting to any site in your farm using Connect-PnPOnline or just https://my-system.mydom.lcl? If you use another accounts, will this error appear? Have a try to update your PnP PowerShell to the latest version and re-exectue the commands.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Okeo-0077 avatar image
0 Votes"
Okeo-0077 answered

Hi AllenXu-MSFT,

thanks for your answer.
The best information in it was the version number: since I used the v1.7.0 it became clear that we are on different projects...

-> I haven't seen that the developer cut off the on premise customers from the PNP.Powershell module :-(

Now using the good old sharepointpnppowershell2019 the Connect-PnPOnline works fine.


Sorry for any inconveniance and thanks again for the hint...

okeo

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.