JanDeDobbeleer / oh-my-posh2

A prompt theming engine for Powershell
MIT License
5.18k stars 281 forks source link

"Install-Module' command was found in the module 'PowerShellGet', but the module could not be loaded. For more information, run 'Import-Module PowerShellGet" error and how to fix it. #269

Closed TheEpicFace007 closed 4 years ago

TheEpicFace007 commented 4 years ago

When I tried to install oh-my-posh it returned me this error so I did

PS C:\Users\ASD\Documents\WindowsPowerShell> Install-Module oh-my-posh -Scope CurrentUser
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 oh-my-posh -Scope CurrentUser
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

I entered the Import-Module PowerShellGet but it gave me this error

PS C:\Users\ASD\Documents\WindowsPowerShell> Import-Module PowerShellGet                            
Import-Module : File                                                                                
C:\Users\ASD\Documents\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psm1     
cannot be loaded because running scripts is disabled on this system. For more information, see      
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.                          
At line:1 char:1                                                                                    
+ Import-Module PowerShellGet                                                                       
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                       
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException               
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand  

To fix the error I did the following thing in a admin powershell prompt

Set-ExecutionPolicy -Scope CurrentUser Bypass

After doing that I entered Import-Module PowerShellGet and Install-Module oh-my-posh -Scope CurrentUser and oh my posh succefully installed!

JanDeDobbeleer commented 4 years ago

That's not really oh-my-posh related (more PowerShell) so I'll close this. Happy you got it to work though!

gulsendemirtaszor commented 3 years ago

Set-ExecutionPolicy -Scope CurrentUser Bypass exactly worked for me. After executing it I could install the following

Install-Module -Name Az