Answered by:
Issues with PackageMangement, PowershellGet and NuGet

Question
-
Server 2016 Standard
Permissions are Enterprise, Domain and Local Server Admin
PS C:\WINDOWS\system32> Install-Module Msonline 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\1.0.0.1\PSModule.psm1:7277 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\1.0.0.1\PSModule.psm1:7291 char:40 + ... ailableNugetProviders = PackageManagement\Get-PackageProvider -Name $ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\AD163521\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y 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\1.0.0.1\PSModule.psm1:7405 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\1.0.0.1\PSModule.psm1:7411 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\1.0.0.1\PSModule.psm1:7415 char:30 + ... $nugetProvider = PackageManagement\Get-PackageProvider -Name $ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Install-Module : 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 + Install-Module Msonline + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Install-Module], InvalidOperationException + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
PS C:\WINDOWS\system32> Install-Module –Name PowerShellGet –Force –Verbose 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\1.0.0.1\PSModule.psm1:7277 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\1.0.0.1\PSModule.psm1:7291 char:40 + ... ailableNugetProviders = PackageManagement\Get-PackageProvider -Name $ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\AD163521\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y VERBOSE: Installing NuGet provider. 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\1.0.0.1\PSModule.psm1:7405 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\1.0.0.1\PSModule.psm1:7411 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\1.0.0.1\PSModule.psm1:7415 char:30 + ... $nugetProvider = PackageManagement\Get-PackageProvider -Name $ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Install-Module : 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 + Install-Module –Name PowerShellGet –Force –Verbose + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Install-Module], InvalidOperationException + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
Tuesday, December 4, 2018 12:24 PM
Answers
-
Solution Found
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\ there were two folders
1.0.0.1 and 1.1.0.0
On our stand by server only the 1.0.0.1 folder existed.
I removed the folder 1.1.0.0 and restarted PS.
All commands now working as expected.
- Marked as answer by Rob Derbyshire Wednesday, December 5, 2018 1:22 PM
Wednesday, December 5, 2018 1:22 PM
All replies
-
You need to troubleshoot and fix your system. If earlier than Windows 10 then you will need to reinstall the package manger. The module the system is looking for is an old module. You may need to manually upgrade the package management system.
In the future note that the first error reported is the only one you need to focus on. The rest are what are referred to as "run-on" errors usually caused by code executing after a fatal error.
\_(ツ)_/
Tuesday, December 4, 2018 12:58 PM -
Thanks for responding.
Its a 2016 Server.
I've been looking for some info on how to repair this but can't find anything relevant.
Wednesday, December 5, 2018 9:57 AM -
You may need to repair your system. That is beyond the scope of this forum.
To start create a new account and try running the install again.
If you installed an older copy of Visual Studio it may have damaged the NuGet Components. If you tried to install NuGet then you may have damaged PowerShell. There is no way for us to know how you caused this to happen.
\_(ツ)_/
Wednesday, December 5, 2018 1:19 PM -
Solution Found
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\ there were two folders
1.0.0.1 and 1.1.0.0
On our stand by server only the 1.0.0.1 folder existed.
I removed the folder 1.1.0.0 and restarted PS.
All commands now working as expected.
- Marked as answer by Rob Derbyshire Wednesday, December 5, 2018 1:22 PM
Wednesday, December 5, 2018 1:22 PM -
Now upgrade PowerShellGet to the latest version or you will have new issues. Whatever you did installed the wrong module. The current module for WS2016 is 2.0.3
\_(ツ)_/
Wednesday, December 5, 2018 1:49 PM -
okay thanks, so how do I do that?
Presume teh issue was that the last time the upgrade completed but did not remove the old version
Wednesday, December 5, 2018 1:51 PM -
The upgrade does not remove old versions.
Update-module PowerShellGet -force
\_(ツ)_/
Wednesday, December 5, 2018 1:59 PM -
Thank you very much by your solution. It works :)
I had the same issue with powershell after doing a system restore point
Tuesday, February 11, 2020 9:42 PM