If when you try to install or update a PowerShell module from PowerShell Gallery on your Windows 11 or Windows 10 computer using the Install-Module or Update-Module command and you get the error message Install-Module or Update-Module command was found in the module PowerShellGet but the module could not be loaded, then you can try the suggestions in this post to resolve the issue.
What is PowerShellGet module?
The PowerShellGet module is the command(s) for discovering, installing, updating and publishing PowerShell artifacts like Modules, DSC Resources, Role Capabilities, and Scripts. As of April 2020, the PowerShell Gallery no longer supports Transport Layer Security (TLS) versions 1.0 and 1.1.
When this issue occurs when you run the Install-Module or Update-Module cmdlet as the case may be, you’ll receive the full error message along the following lines;
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’.
Furthermore, when you try and run Import-Module PowerShellGet as per the preceding error message, you receive either of the following error message;
Import-Module: The required module ‘PackageManagement’ is not loaded. Load the module or remove the module from ‘RequiredModules’ in the file.
OR
Import-Module: The cloud file provider is not running.
The second subsequent error message above appears to be OneDrive-related.
Install-Module command was found in the module PowerShellGet but the module could not be loaded
If the error Install-Module command was found in the module PowerShellGet but the module could not be loaded has occurred on your Windows 11/10 PC, you can try our recommended solutions below in no particular order and see if that helps to resolve the issue on your system.
- Set Execution Policy to Unrestricted
- Enable OneDrive Personal (if applicable)
- Sign into another User Account or Create new User Account
- Reset Windows 11/10
Before you proceed with the solutions below, make sure PowerShell is updated and Transport Layer Security v1.2 or newer is enabled and set as the default protocol in the PS Session – then run the command below in elevated command prompt:
powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
Once the command executes, retry the PowerShell module install/update and see if successful.
1] Set Execution Policy to Unrestricted
Most affected users were able to resolve the Install-Module command was found in the module PowerShellGet but the module could not be loaded error that occurred on their Windows 11/10 PC by simply setting ExecutionPolicy to unrestricted. To perform this task, you can follow the instructions in the guide on how to fix PowerShell cannot be loaded because running scripts is disabled.
2] Enable OneDrive Personal (if applicable)
This solution worked for affected PC users running the Update-Module cmdlet – and when running the Import-Module PowerShellGet cmdlet received the error message The cloud file provider is not running.
It turns out this scenario applied to a user with OneDrive Business accounts, all of which were set up correctly. However, OneDrive Personal account was not running, and the personal OneDrive PowerShell folder was on the $env:PSModulePath path.
In this case, to resolve the issue, you need to re-enable the OneDrive Personal account. To perform this task, you can follow the instructions in the guide on how to fix OneDrive not opening on startup in Windows 11/10.
3] Sign into another User Account or Create new User Account
If you have multiple user accounts set up on your Windows 11/10 PC, this solution requires you to sign out of the active account and then sign into another account on your PC and then run the PowerShell module install or update operation again. Some affected PC users reported this worked for them. However, if you do not have other user account on your PC, you can create a new user account.
4] Reset Windows 11/10
At this point, if nothing has worked for you to resolve the issue at hand, you can reset your Windows 11/10 PC – when performing the reset operation, choose the option to keep your personal files. After the reset, try the Install-Module or Update-Module as the case may be and see if the task completes without issues. Otherwise, retry the fixes mentioned above.
Related post: PowerShell Get-Appxpackage Not working or Access Denied
How do I install a PowerShellGet module?
To install the latest version of PowerShellGet module on Windows 11/10 system, do the following:
- Set TLS1.2 as default protocol in the PS Session.
- Before updating PowerShellGet, you should always install the latest NuGet provider.
- Register PS repositories if not setup before.
- Install PowerShellGet.
How do I update a PowerShellGet module?
To update PowerShellGet and PackageManagement, run the following commands:
- Get-Module -ListAvailable PackageManagement, PowerShellGet.
- Install-PackageProvider Nuget –Force Exit.
- Install-Module –Name PowerShellGet –Force Exit.
- Set-ExecutionPolicy RemoteSigned Install-Module –Name PowerShellGet –Force -AllowClobber.
How do I know if PowerShellGet is installed?
To test if PowerShellGet is installed on a Windows 11/10 computer, run the Get-Module -ListAvailable PowerShellGet command. From a PowerShell session, use Save-Module to download the current version of PowerShellGet. Two folders are downloaded: PowerShellGet and PackageManagement. Each folder contains a subfolder with a version number.