The essentials

Quick reference

One focused task per row. Jump to the related section for complete, working examples.

UseSyntaxExamples
List available module versionsGet-Module -ListAvailable Pester | Sort-Object Version -DescendingView examples
List loaded modulesGet-Module | Sort-Object Name, VersionView examples
Inspect module search paths$env:PSModulePath -split [IO.Path]::PathSeparatorView examples
List repositoriesGet-PSResourceRepository | Sort-Object Priority, NameView examples
Find exact resourceFind-PSResource -Name Pester -Version 5.6.1 -Repository ` PSGalleryView examples
List available versionsFind-PSResource -Name Pester -Version '*' -Repository PSGallery | Sort-Object Version -DescendingView examples
Stage a module packageSave-PSResource -Name Pester -Version 5.6.1 -Repository ` PSGallery -Path './staging'View examples
Validate a manifestTest-ModuleManifest -Path ` './staging/Pester/5.6.1/Pester.psd1'View examples
Inspect script signaturesGet-ChildItem './staging/Pester' -Recurse -File -Include '*.ps1','*.psm1' | Get-AuthenticodeSignatureView examples
Preview current-user installInstall-PSResource -Name Pester -Version 5.6.1 ` -Repository PSGallery -Scope CurrentUser -WhatIfView examples
List installed resourcesGet-InstalledPSResource -Name Pester | Sort-Object Version -DescendingView examples
Preview module updateUpdate-PSResource -Name Pester -WhatIfView examples
Import a pinned versionImport-Module -FullyQualifiedName @{ ModuleName = ` 'Pester'; RequiredVersion = '5.6.1' } -ErrorAction ` StopView examples
Inspect exported commandsGet-Command -Module Pester | Sort-Object NameView examples
Unload from sessionRemove-Module -Name Pester -ForceView examples
Preview uninstallUninstall-PSResource -Name Pester -Version 5.6.1 -Scope ` CurrentUser -WhatIfView examples

PowerShell modules execute code with the caller's privileges, and repository priority can decide which publisher's package satisfies an unqualified name. Inventory installed and loaded versions separately, qualify repository and version, inspect manifests and staged package contents, and test upgrades in a fresh constrained environment. PSResourceGet is the current package-management interface; Windows PowerShell environments may still expose PowerShellGet v2 commands with different names and behavior.

Step by step

Detailed examples

01

Separate discoverable, installed, and loaded state

Get-Module reports the current session, while -ListAvailable searches PSModulePath. PSResourceGet inventory covers packages it manages and may not include modules copied manually or supplied by Windows. Multiple side-by-side versions are normal; command resolution can change when search paths, autoloading, or import order changes.

Capture module resolution context
$env:PSModulePath -split [IO.Path]::PathSeparator
Get-Module -ListAvailable Pester | Select-Object Name, Version, Path
Get-Module Pester | Select-Object Name, Version, Path
Get-InstalledPSResource -Name Pester -ErrorAction SilentlyContinue
Back to quick reference ↑
02

Resolve by repository, name, and version

Repository trust suppresses prompts; it does not prove that every package or publisher is safe. A lower numeric priority has higher precedence in PSResourceGet, so unqualified lookups can select an unintended source. Review repository URI, ownership, TLS and authentication controls, then qualify critical automation by repository and a tested version range or exact version.

Inspect precedence and resolve one immutable candidate
Get-PSResourceRepository | Sort-Object Priority, Name | Format-Table Name, Uri, Trusted, Priority, ApiVersion
Find-PSResource -Name Pester -Version 5.6.1 -Repository PSGallery | Select-Object Name, Version, Repository, Author, PublishedDate
Back to quick reference ↑
03

Stage and inspect before executing package code

Installation places code in a module search path, and importing it can execute module initialization. Save to a non-PSModulePath staging directory, inspect manifest-declared nested modules, scripts, dependencies, licenses, file hashes, and signatures, and scan with organizational controls. Test-ModuleManifest validates structure, not publisher intent or runtime safety.

Stage a pinned version for security review
Save-PSResource -Name Pester -Version 5.6.1 -Repository PSGallery -Path './staging'
Test-ModuleManifest -Path './staging/Pester/5.6.1/Pester.psd1'
Get-ChildItem './staging/Pester/5.6.1' -Recurse -File | Get-FileHash -Algorithm SHA256
Get-ChildItem './staging/Pester/5.6.1' -Recurse -File -Include '*.ps1','*.psm1' | Get-AuthenticodeSignature
Back to quick reference ↑
04

Install narrowly and treat updates as code changes

CurrentUser scope normally avoids elevation; AllUsers writes to shared locations and requires administrative rights. WhatIf previews supported package actions but cannot assess package runtime behavior. Pin versions in repeatable environments, review dependency changes, install into a test profile, and start a fresh PowerShell process before validating an upgraded module.

Preview a pinned install and update
Install-PSResource -Name Pester -Version 5.6.1 -Repository PSGallery -Scope CurrentUser -WhatIf
Get-InstalledPSResource -Name Pester | Sort-Object Version -Descending
Update-PSResource -Name Pester -WhatIf
Back to quick reference ↑
05

Import explicitly and verify the resulting command surface

Installing does not load the new version into the current session. Existing modules and commands can remain bound until a new process starts. Use RequiredVersion for an exact pin; ModuleVersion is a minimum version. Add ErrorAction Stop and optionally Prefix or NoClobber when collision policy requires it. Then verify the loaded path, version, exported commands, and representative behavior.

Load and verify the selected version
Import-Module -FullyQualifiedName @{ ModuleName = 'Pester'; RequiredVersion = '5.6.1' } -ErrorAction Stop
Get-Module Pester | Select-Object Name, Version, Path
Get-Command -Module Pester | Sort-Object Name | Select-Object Name, CommandType, Source
Back to quick reference ↑
06

Diagnose resolution before removing anything

Import failures may result from edition compatibility, execution policy, missing dependencies, command collisions, architecture, or an unexpected path. Capture $PSVersionTable, module paths, available versions, and the full error first. Remove-Module only unloads this process; Uninstall-PSResource deletes files and can break other automation, so preview it and retain a reinstallable approved version.

Collect diagnostics and preview rollback
$PSVersionTable
Get-Module -ListAvailable Pester | Select-Object Name, Version, Path
Get-Error -Newest 1
Remove-Module -Name Pester -Force -ErrorAction SilentlyContinue
Uninstall-PSResource -Name Pester -Version 5.6.1 -Scope CurrentUser -WhatIf
Back to quick reference ↑

Sources and further reading

References

Authoritative documentation used to verify and expand this cheat sheet.

  1. MicrosoftMicrosoft.PowerShell.PSResourceGet Modulelearn.microsoft.com
  2. MicrosoftInstall-PSResourcelearn.microsoft.com
  3. Microsoftabout_PSResourceGetlearn.microsoft.com
  4. MicrosoftImport-Modulelearn.microsoft.com

Help us improve

Found a typo or missing example?

Tell us what would make this cheat sheet clearer, more complete, or more useful.

Share feedback