Modules
A module is a package of commands. Import-Module loads one, Get-Module shows what is loaded, and Get-Module -ListAvailable shows what is installed and could be loaded.
Documentation: Microsoft Learn
Overview
Auto-loading means you rarely call Import-Module by hand. Use a command from an installed module and PowerShell loads the module for you. You still need Import-Module when the module is somewhere unusual, when you want a specific version with -RequiredVersion, or when you need to force a reload.
Installing comes from the gallery: Install-Module Pester -Scope CurrentUser. Use -Scope CurrentUser unless you deliberately want the module available to every account on the machine, because the machine-wide path needs administrator rights.
The two editions have separate module paths, which explains a common confusion. A module installed under Windows PowerShell 5.1 does not automatically appear in PowerShell 7. Check $env:PSModulePath in the edition that cannot see it.
What happens
-ListAvailable widens the search from loaded modules to every module on the module path. Sorting by name makes the list readable and Select-Object trims it to six rows and three columns. ModuleType tells you how each one is implemented: Manifest, Script or Binary.
Worth remembering
- Get-Module shows loaded. -ListAvailable shows installed.
- Auto-loading means Import-Module is usually optional.
- Install with -Scope CurrentUser to avoid needing admin rights.
- 5.1 and 7 have separate module paths.
Primary documentation
Try it
Browser simulation · fictional data; no changes to your computer.
Follow the objects
Run the command to inspect each stage.
Lists six installed modules with their versions and types.
Show reference output
Browser dataset output · the real environment will differ
Name Version ModuleType ------------------------------- ------- ---------- ActiveDirectory 1.0.1.0 Manifest Microsoft.PowerShell.Management 7.0.0.0 Manifest Pester 5.6.1 Script
Practise this
Import the testing module
Import Pester, then display the Pester module record.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.