Get Module - PowerShell


Overview

Get-Module is a fundamental PowerShell command that retrieves information about loaded modules. It enables the exploration and management of modules within the current PowerShell session, facilitating efficient PowerShell script development and execution.

Syntax

Get-Module [-ListAvailable] [-Name] [-RequiredVersion] [-Script]

Options/Flags

  • -ListAvailable: Lists all available modules, even those not currently loaded.
  • -Name: Filters the output to only show modules matching the specified name pattern. Accepts wildcards (*).
  • -RequiredVersion: Filters the output to only show modules that meet the specified minimum version requirement.
  • -Script: Displays information about script modules loaded in the current session.

Examples

# List all loaded modules
Get-Module

# List all available modules
Get-Module -ListAvailable

# Filter modules by name
Get-Module -Name PowerShell*

# Check the version of a specific module
Get-Module -Name PSSession | Format-Table Name, Version

Common Issues

  • Module not found: Ensure the module is installed and loaded before attempting to use it. Use Import-Module or specify the -Script parameter to load script modules.
  • Access denied: If encountering permission issues, try running the command from an elevated PowerShell session (run as administrator).

Integration

  • Import-Module: Loads a module into the current session, making its cmdlets, functions, and variables accessible.
  • Remove-Module: Unloads a module from the session, removing its functionality.
  • Command chaining: Combine Get-Module with other commands, such as Format-Table or Export-CSV, to customize and export the module information.