Share via

PowerShell Connect pnp Command

Pandikumar Subramanian 0 Reputation points
2023-04-11T14:41:45.1+00:00

Hello All, I am trying to run command "Connect-PnPOnline" but I am getting below error message. I tried to use Import-PnPOnline and also Install-PnPOnline, but none of them were worked properly. Request you to guide me step by step to resolve this errors.. I am new to this Powershell and unable identify the errors.

onnect-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'.
At line:1 char:1
+ Connect-PnPOnline -Url "https://contoso.sharepoint.com" -UseWebLogin
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Connect-PnPOnline:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

And also when I tried to "Import-Module PnP.PowerShell", I am getting below error message. 
Import-Module : The specified module 'PnP.PowerShell' was not loaded because no valid module file was found in any module 
directory.
At line:1 char:1
+ Import-Module PnP.PowerShell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (PnP.PowerShell:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

PS C:\WINDOWS\system32> Install-Module -Name PnP.PowerShell
Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operable 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Install-Module -Name PnP.PowerShell
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2023-04-12T06:45:48.35+00:00

    Hi @Pandikumar Subramanian,

    Per my research, I do agree with Rich Matheisen's answer. You can try the solution to fix the answer. And if you are using an old version powershell, this might also cause the error. Please try to update the powershell to the latest version and reinstall the pnp module.

    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.

    Was this answer helpful?


  2. Rich Matheisen 48,116 Reputation points
    2023-04-11T15:04:27.8933333+00:00

    This: "The term 'Install-Module' is not recognized as the name of a cmdlet" is the problem.

    If you run this: $ExecutionContext.SessionState.LanguageMode, what is the result? If it reports anything other than "FullLanguage" see your administrator.

    https://stackoverflow.com/questions/66210483/install-module-not-available-not-recognized-as-a-name-of-a-cmdlet

    Was this answer helpful?

    0 comments No comments

Your answer

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