PowerShell’s Install-Module
cmdlet downloads one or more modules from a repository and installs them on the local computer. But, when you run Install-Module
, you may get the following error:
Install-Module : The ‘Install-Module’ command was found in the module ‘PowerShellGet’, but the module could not be loaded. For more information, run ‘Import-Module PowerShellGet’.
At line:1 char:1
+ Install-Module
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNo
The Install-Module
cmdlet is available only on PowerShell 5.1 & higher, and the Windows 7 & 8 systems needed a PowerShell version upgrade to use this cmdlet. However, on Windows 7, 8 systems with older versions of PowerShell, running the command shows the following error which is slightly different than the above:
‘Install-Module’ is not recognized as the name of a cmdlet, function, script file, or operable program.
However, the above error may also occur in a Windows 10 computer which already includes PowerShell 5.1. Running the $PSVersiontable
command showed the PowerShell version on my Windows 10 v1903 system as 5.1.18362.145.
PSVersion 5.1.18362.145 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.18362.145 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Then, why doesn’t the Install-Module
cmdlet work?
Install-Module command was found in the module PowerShellGet
The error Install-Module command was found occurs if the script execution policy is set to Restricted. To use the cmdlet, set the execution policy to Unrestricted, using the following command.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
The above command sets the execution policy to Unrestricted for the current PowerShell session.
If you want to set it permanently for the current user, then use this command:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
To set it permanently for the local machine, use this command from elevated or admin PowerShell:
Set-ExecutionPolicy Unrestricted -Scope LocalMachine
For more information, see Microsoft documentation on Set-ExecutionPolicy.
One small request: If you liked this post, please share this?
One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!
I’ve set my execution policy to Unrestricted, but I’m still getting the same error. Any other ideas?
PS C:\WINDOWS\system32> Get-ExecutionPolicy
Unrestricted
PS C:\WINDOWS\system32> Find-Module -Name MicrosoftPowerBIMgmt
Find-Module : The ‘Find-Module’ command was found in the module ‘PowerShellGet’, but the module could not be loaded. For more
information, run ‘Import-Module PowerShellGet’.
At line:1 char:1
+ Find-Module -Name MicrosoftPowerBIMgmt
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Find-Module:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule