7

I am trying to install the PnP online commands for SharePoint onto my PowerShell however the following command doesn't seem to work;

Install-Module -name SharePointPnPPowerShellOnline -scope CurrentUser

The command seems to run through fine with no errors appearing but when I try to run Commands which should have been installed I get an error saying the commands can not be found.

connect-pnponline : The term 'connect-pnponline' 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
+ connect-pnponline
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (connect-pnponline:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I have had a look at all the module folders and the module is not in any of them. I have compared my environment paths with a coworker who has this working and they are the same.

Does anyone know what might be causing this?

3
  • 1
    Try adding the -verbose parameter to see if that gives you any clues, at the very least it should list out the available commands. It could be that your version of the module doesn't contain the command you are trying. Commented Sep 11, 2020 at 10:57
  • What does Get-Module "SharePointPnPPowerShellOnline" -ListAvailable show you? Commented Sep 11, 2020 at 11:50
  • You tried importing the module after you installed it? e.g Import-Module SharePointPnPPowerShellOnline Commented Sep 11, 2020 at 12:59

4 Answers 4

5

This was caused by by modules being stored on OneDrive. By default my module path was set to "%USERPROFILE%\Documents\WindowsPowerShell\Modules" but since i had OneDrive installed my path changed to "%USERPROFILE%\OneDrive\Documents\WindowsPowerShell\Modules".

To resolve this issue I went to Documents>Windows Powershell>Modules and copied the link. Then, via the Start' menu, I went to 'Edit the system environment variables'>advanced>Environment Variables, highlighted PSModulePath and clicked Edit. Once in this window I clicked New and pasted the link I found above. This resolved the problem I was experiencing.

Sign up to request clarification or add additional context in comments.

Comments

2

The module probably isn't imported. You should be able to execute
Import-Module SharePointPnPPowerShellOnline which should either import your module, or give you an error if it can't be imported for some reason.

To tackle the non-autoloading issue, check the following:

1 Comment

I had the same problem after uninstalling the module. It won't re-install it. I added "-Force" and it worked!
0

I had the same symptom The term '' is not recognized..., but a different fix.

When I checked $ENV:PSModulePath in Windows Powershell (this problem was not present in pwsh powershell core), I saw the expected folder C:\Users\cwalsh\OneDrive\Documents\WindowsPowerShell\Modules was missing:

Instead $ENV:PSModulePath was ;;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\

The root cause was I had PSModulePath env var defined at both User-level as ; (this is not how my other PC is set up), and at System-level as %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\. I guess unlike PATH this variable doesn't automatically concatenate both.

I deleted the user-level PSModulePath environment variable and now in a new process the module works as expected.

Comments

0

Onedrive syncing screwed up the files for MgGraph authentication. one of the subfolders sync was broken he file was removed because "cloud" didnt know about it. Had to reinstall... Need to change the default location out of documents if you have onedrive so silly

1 Comment

This answer is based on a personal experience that is too local to make it comprehensible as a generic answer. Also, how does this add anything to the already sufficient answers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.