Friday, May 31, 2019

(fixed) Import-Module: The specified module was not loaded because no valid module file was found in any module directory

I tried to load module 'CredentialManager' through the script below:

Import-Module CredentialManager -DisableNameChecking

And got error:

Import-Module: The specified module "CredentialManager" was not loaded because no valid module file was found in any module directory

Then I ran "Get-InstalledModule" to check it.

No problem, the module was installed. Then why I cannot import it?

$env:PSModulePath shows:

C:\Users\username\AppData\Local\Apps\SharePointPnPPowerShellOnline;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell
\v1.0\Modules;C:\Program Files\SharePoint Online Management Shell\

Emmm...."C:\Users\username\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules" is not there.

I can fix the problem by adding this path to PSModulePath environment variable. But, I believe the better way is to re-install "CredentialManager".

Uninstall-Module CredentialManager
Install-Module CredentialManager

After the re-installation, this module appeared in "C:\Program Files\WindowsPowerShell\Modules"

Great!

No comments:

Post a Comment