Connect-PnPOnline fails - how to debug?

Okeo 21 Reputation points
2021-09-03T15:12:22.717+00:00

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

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,590 questions
0 comments No comments
{count} votes

Accepted answer
  1. Allen Xu_MSFT 13,791 Reputation points
    2021-09-06T07:06:34.417+00:00

    Hi @Okeo ,

    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Okeo 21 Reputation points
    2021-09-06T12:36:47.677+00:00

    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

    0 comments No comments