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

Sophie von Brühl 10 Reputation points
2023-05-19T13:20:57.9266667+00:00

I want to connect to PnP.PowerShell, but when I execute this command:

Connect-PnPOnline -Url <> -Interactive

I obtain this error:

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'.

When I run:

Import-Module PnP.PowerShell

I obtain this error:

Import modules: The file or assembly "System.Management.Automation, Version=7.2.0.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35" or a dependency on it was not found. The system cannot find the specified file

File.

Can anybody help me?

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Sophie von Brühl 10 Reputation points
    2023-05-26T15:12:41.3133333+00:00

    The error came because I had Powershell version 5.xx, but you need 7.xx.

    I was able to fix the error by completely reinstalling Powershell in the 7 version.

    1 person found this answer helpful.
    0 comments No comments

  2. Limitless Technology 44,771 Reputation points
    2023-05-22T12:48:10.27+00:00

    Hello

    Thank you for your question and reaching out.

    Make sure the 'PnP.PowerShell' module is set up. In an elevated PowerShell session, enter the following command to install it if you haven't already:

    Install-Module -Name PnP.PowerShell

    Try manually importing the module using the 'Import-Module' command if it has already been installed:

    Import-Module PnP.PowerShell

    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

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.