Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Uninstall-Module of older version

Tags:

powershell

The system appears to have two (2) versions of PowerShellGet module installed.

Script     2.2        PowerShellGet
Script     1.0.0.1    PowerShellGet

How can I uninstall the older version? The Uninstall-Module command appears to be looking in the 2.2 directory. Why is that?

>Uninstall-Module -Name 'PowerShellGet' -RequiredVersion '1.0.0.1'
PackageManagement\Uninstall-Package : No match was found for the specified search criteria and module names 'PowerShellGet'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2\PSModule.psm1:12655 char:21
+ ...        $null = PackageManagement\Uninstall-Package @PSBoundParameters
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package], Exception
    + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage

When I try to specify the older version, it reports the new version.

>Get-Module -FullyQualifiedName @{ModuleName="PowerShellGet";ModuleVersion="1.0.0.1"}

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.2        PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}

>($PSVersionTable.PSVersion).ToString()
5.1.14409.1018
>(Get-CimInstance -ClassName Win32_OperatingSystem).Caption
Microsoft Windows 7 Enterprise
like image 869
lit Avatar asked Aug 16 '19 21:08

lit


1 Answers

Short answer:

You can't that uninstall something with PowerShellGet if it wasn't installed with PowerShellGet.

Long answer:

PowerShellGet v1.0.0.1 was installed as a part of Windows, and not using PowerShellGet (naturally). Hence, why you can't use PowerShellGet to Uninstall-Module it.

PowerShellGet v2.2 on the other hand, is installed with PowerShellGet and so you can Uninstall-Module it. You can also update it etc.

If you really want to uninstall the v1.0.0.1 version, you have to follow these Steps:

  1. Browse to C:\Program Files\WindowsPowerShell\Modules\
  2. Go into C:\Program Files\WindowsPowerShell\Modules\PowershellGet folder, and delete the sub- folder 1.0.0.1
  3. Then do the same for C:\Program Files\WindowsPowerShell\Modules\PackageManagement, delete the sub-folder 1.0.0.1
like image 94
HAL9256 Avatar answered Sep 25 '22 14:09

HAL9256