Fix The ‘Install-Module’ command was found in the module ‘PowerShellGet’

Hi Everyone this is Prem, I have worked as Microsoft 365 support ambassador. In this blog I will share how to Fix The ‘Install-Module’ command was found in the module ‘PowerShellGet’, but the module could not be loaded. For more information, run ‘Import-Module PowerShellGet’ error.

 

This issue can occur when we are trying to connect to the powershell to office 365 services like Exchange online, Microsoft admin center, etc and we try to Install the respective module.

 

When we run the Install-Module command it gives us the error The ‘Install-Module’ command was found in the module ‘PowerShellGet’, but the module could not be loaded. For more information, run ‘Import-Module PowerShellGet’

 

Let se How we can fix The ‘Install-Module’ command was found in the module ‘PowerShellGet’, but the module could not be loaded error:

 

When connecting with PowerShell to any Office 365 service make sure the PowerShell is ran as an Administrator when launching:

 

Search for windows PowerShell on your computer and run it as an administrator:

 Fix The ‘Install-Module’ command was found in the module ‘PowerShellGet’

Once opened it should look like this:

 Fix The ‘Install-Module’ command was found in the module ‘PowerShellGet’

And Now if I try to run the command to install exchange online module command then it might give me the following error:

Fix The 'Install-Module' command was found in the module 'PowerShellGet'

To fix this I will have to check by Execution policy set on the computer, I can check the same by running the following command:

 

Get-ExecutionPolicy

The output of the above command will look something like this:

Fix The 'Install-Module' command was found in the module 'PowerShellGet'

For my computer it is set to Restricted, Now I can allow it for everyone to be able to install modules who are using the computer or just myself by running the below command respectively:

 

To allow everyone using the computer be able to run Install-module commands without the error run the following command:

Set-ExecutionPolicy RemoteSigned

Fix The ‘Install-Module’ command was found in the module ‘PowerShellGet’

After you run the above command you will be prompted to confirm the changes, you can type A as shown above or Y. This will set the policy and you should then be able to run the Install-Module command respectively.

 

If you get error: Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by

a policy defined at a more specific scope. Run the below command which is of smaller scope.

 

To allow only your account using the computer be able to run Install-module commands without the error run the following command:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Fix The ‘Install-Module’ command was found in the module ‘PowerShellGet’

After you run the above command you will be prompted to confirm the changes, you can type A as shown above or Y. This will set the policy and you should then be able to run the script.

 

Setting the execution policy as RemoteSigned allow it to run the script or files which are signed by trusted publisher.

 

After running the above command successfully you should be able to install the module which you want.

 

If you are looking to connect the PowerShell with specific office 365 services you can refer the below article respectively:

 

How to Connect to Microsoft 365 Admin Center using PowerShell

or How to Connect to SharePoint Online using PowerShell

or How to connect to Exchange Online using PowerShell in Office 365

 

If you have any question please drop it in the comment section.

 

Date:26/02/2023

Author: Prem

Leave a Comment

Your email address will not be published. Required fields are marked *