Reputation: 61
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.
Upvotes: 6
Views: 22473
Reputation: 1
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 $ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
+ CategoryInfo : InvalidOperation: (:) [Set-PSRepository], InvalidOperationException
+ FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Set-PSRepository
PS C:\temp>
Upvotes: 0
Reputation: 483
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
Upvotes: 4
Reputation: 1196
Execute the command on your powershell: 'Set-ExecutionPolicy Unrestricted' before executing install-module. (The restricted mode helps you protect from the the unauthorized scripts)
Upvotes: 9