The 'Connect-PnPOnline' command was found in the module 'PnP.PowerShell', but the module could not be loaded.

Aran Billen 941 Reputation points
2024-02-29T09:10:02.5766667+00:00

Hi all, When I run command Connect-PnPOnline i get the below message:  

Connect-PnPOnline : 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'.  whenI then run Import-Module PnP.PowerShell I get:

 Import-Module : Could not load file or assembly 'System.Management.Automation, Version=7.2.0.0, Culture=neutral,  PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. At line:1 char:1 

Hi all, When I run command Connect-PnPOnline i get the below message:  Connect-PnPOnline : 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'.  whenI then run Import-Module PnP.PowerShell I get:  Import-Module : Could not load file or assembly 'System.Management.Automation, Version=7.2.0.0, Culture=neutral,  PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. At line:1 char:1  How do I fix this?

Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft 365 and Office | SharePoint | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
{count} votes

Accepted answer
  1. Emily Du-MSFT 51,861 Reputation points Microsoft External Staff
    2024-03-01T10:03:39.7666667+00:00

    What is the version of installed PnP PowerShell? This issue may be caused by the newer version of PnP PowerShell. You need to forcefully install the 1.12.0 version.

    Please run following PowerShell.

    1.Uninstall-Module PNP.PowerShell -AllVersions

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

    3.Install-PackageProvider -Name nuget -MinimumVersion 2.8.5.201 -force

    4.Install-Module -Name "PnP.PowerShell" -RequiredVersion 1.12.0 -Force –AllowClobber


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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