Get InstalledModule - PowerShell


Overview

The Get-InstalledModule command in PowerShell retrieves a list of all installed PowerShell modules, both installed in the current session and those registered in the system. This is useful for managing installed modules, updating them, or resolving any module dependency issues.

Syntax

Get-InstalledModule [[-Name] <string[]>] [-AllVersions] [-Hidden] [-RequiredVersion <string>] [-AllowPrerelease] [-EA <ActionPreference>]

Options/Flags

  • -Name: Specifies a list of module names to filter the results.
  • -AllVersions: Includes all installed versions of a module in the output.
  • -Hidden: Shows hidden modules.
  • -RequiredVersion: Specifies a required minimum version for the module(s).
  • -AllowPrerelease: Includes prerelease versions of modules in the output.
  • -EA: Error action preference.

Examples

  • Get all installed modules:
Get-InstalledModule
  • Get a specific module:
Get-InstalledModule -Name PSReadline
  • Get all versions of a module:
Get-InstalledModule -AllVersions -Name PSReadline
  • Show hidden modules:
Get-InstalledModule -Hidden
  • Get modules installed during the current session:
Get-InstalledModule | Where { !$_.IsPersistent }

Common Issues

  • Module not found error: Ensure that the module you’re trying to retrieve is installed by running Find-Module.
  • Ambiguous module name error: If multiple modules have the same name, use the -AllVersions flag to see all versions and their full names.
  • Module dependency errors: Some modules may depend on other modules that are not installed. Use the -RequiredVersion flag to specify the minimum version of the dependent module.

Integration

Get-InstalledModule can be combined with other PowerShell commands for advanced tasks, such as:

  • Installing or updating modules: Use Install-Module or Update-Module with the -Name parameter to specify the modules to manage.
  • Managing dependencies: Use Resolve-ModuleDependency to ensure that all necessary dependencies are met.
  • Find-Module: Searches for PowerShell modules, both installed and available online.
  • Import-Module: Imports a module into the current session.
  • Remove-Module: Removes a module from the system.