Search code examples
powershell-4.0

Powershell Modules: Get-Module -All vs Get-InstalledModule


When I run Get-InstalledModule I see Version 3.0.1 of a module that I'm interested in. When I run "Get-Module -all" I see 2.7.1 of that same module.

So which one is actually being used? How can I clean-up and remove the old 2.7.1 version?


Solution

  • Running Get-Module without the -ListAvailable parameter shows only what's been imported into the current PowerShell session. These could be modules you've imported manually using the "Import-Module" command, or ones that were imported automatically (in PowerShell v3 and up) once you tried running a command from one of them.

    Get-InstalledModule shows all installed modules. The most recent version should auto-import by default, but if you want to clean up old versions, use the command "Uninstall-Module -Name modulename -RequiredVersion version", to specify the version you want to uninstall.