Reputation: 121
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?
Upvotes: 7
Views: 11427
Reputation: 1
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
Upvotes: 0
Reputation: 6999
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.
Upvotes: 0
Reputation: 121
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.
Upvotes: 5
Reputation: 21488
The module probably isn't imported. You should be able to executeImport-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:
$PSModuleAutoLoadingPreference
and that it's not set to None
or 0
SharePointPnPPowerShellOnline
implements a SharePoint provider so I'd wager this is the case.Upvotes: 2