Connect-PnPOnline fails after updating PnP.PowerShell to v2.1.1
Notice
Many bugs reported are actually related to the PnP Framework which is used behind the scenes. Consider carefully where to report an issue:
- Are you using
Invoke-PnPSiteTemplateorGet-PnPSiteTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/pnp/pnpframework/issues. - Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
- If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/pnp/powershell/tree/master/src/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/pnp/pnpframework/issues
Reporting an Issue or Missing Feature
Please confirm what it is that your reporting As part of connecting to SharePoint to download files, I've been using "Connect-PnPOnline" and it was working fine, until I updated the "PnP.Powershell" library to v2.1.1 After the update the same PS script which ran successfully fails with the following error:
Error: The 'Connect-PnPOnline' command was found in the module 'PnP.PowerShell', but the module could not be loaded. For more information, run 'Import-Module PnP.PowerShell'.
Expected behavior
Please describe what output you expect to see from the PnP PowerShell Cmdlets Connect-PnPOnline should be working as before
Actual behavior
Please describe what you see instead. Please provide samples of output or screenshots. Error: The 'Connect-PnPOnline' command was found in the module 'PnP.PowerShell', but the module could not be loaded. For more information, run 'Import-Module PnP.PowerShell'.
Steps to reproduce behavior
Please include complete script or code samples in-line or linked from gists Connect-PnPOnline -Url $url -Credentials $cred
What is the version of the Cmdlet module you are running?
(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)
v2.1.1
Which operating system/environment are you running PnP PowerShell on?
- [x] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
Had the same issue. For us, it is Add-PnPStoredCredential command and Import-Module does not solve it either. Also opened a discussion ticket here: https://github.com/pnp/powershell/discussions/2964
@Subi-Sri @LiyuanWang123 - v2.1.1 does not support PS5 nor the ISE, you need to use PS7.
If you are still using PS5, you can use v1.12.0 however bug fixes and improvements will only be done on the 2.x releases in the future.
@veronicageek We are using PS7 though.
This is what I'm seeing.

@LycheeYum - If you've updated / installed the module version 2.1.x in PowerShell 5 it's not going to work. And your screenshot show Windows PowerShell. Also, you need to connect to your SPO site, not run Connect-PnPOnline on its own.
Connect-PnPOnline works fine or we would have had a lot of reports.

Thank you! Turns out I was on PowerShell 5 The $PSversionTable command is handy. I assumed that I was on 7 since I ran the installer for it without issue.
This time I installed PS 7 from the Microsoft Store and all is well.

Thanks again!