6

I am working on Windows 2012 R2 and it was running PowerShell version 4.0. I have upgraded to version 5.0.

It seems like that when I do basic commands I get errors, for example,

PS C:\Windows\system32> Install-Module –Name PowerShellGet –Force –Verbose

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 –Name PowerShellGet –Force –Verbose + ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Another example:

PS C:\Windows\system32> import-module PowerShellGet

Get-Variable : The term 'Get-Variable' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.3.2\PSModule.psm1:18 char:28 + $script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction ... + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-Variable:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

I am basically following the installation method for PowerShellGet found here: https://learn.microsoft.com/en-us/powershell/gallery/psget/get_psget_module

I am stuck at the "Install-Module" command in this guide.

1
  • Hi Geoff, welcome to SO! Please take a moment and look into this to improve your questions and formatting: stackoverflow.com/help/how-to-ask Commented Sep 14, 2017 at 19:02

3 Answers 3

10

Execute the command on your powershell: 'Set-ExecutionPolicy Unrestricted' before executing install-module. (The restricted mode helps you protect from the the unauthorized scripts)

Sign up to request clarification or add additional context in comments.

Comments

5

I know I too late to answer this question. But may help to others.

Try following ,

Set-ExecutionPolicy Unrestricted
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted

and now you can try install-module

Comments

0

This didn't work for me

PS C:\temp> Set-PSRepository -NAME PSGallery -InstallationPolicy Trusted PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:2934 char:26

  • ... $nugetProvider = PackageManagement\Get-PackageProvider -ErrorA ...
  •                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:2948 char:40

  • ... ailableNugetProviders = PackageManagement\Get-PackageProvider -Name $ ...
  •                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

PackageManagement\Install-PackageProvider : The term 'PackageManagement\Install-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3138 char:21

  •         $null = PackageManagement\Install-PackageProvider -Name $ ...
    
  •                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (PackageManageme...PackageProvider:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

PackageManagement\Import-PackageProvider : The term 'PackageManagement\Import-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3144 char:21

  •         $null = PackageManagement\Import-PackageProvider -Name $s ...
    
  •                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (PackageManagement\Import-PackageProvider:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3148 char:30

  • ... $nugetProvider = PackageManagement\Get-PackageProvider -Name $ ...
  •                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

Set-PSRepository : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed. At line:1 char:1

  • Set-PSRepository -NAME PSGallery -InstallationPolicy Trusted
  •   + CategoryInfo          : InvalidOperation: (:) [Set-PSRepository], InvalidOperationException
      + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Set-PSRepository
    
    
    

PS C:\temp>

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.