PowerShell modules can be distributed, discovered, and installed directly from package repositories using package management cmdlets. The primary public repository is the PowerShell Gallery (PSGallery), maintained by Microsoft, which hosts thousands of community and vendor modules for cloud management, system administration, and developer tooling. The PowerShellGet module, and its newer successor PSResourceGet, provides the cmdlets to find, install, update, and save these modules.
Finding Modules with Find-Module
The Find-Module cmdlet searches the PowerShell Gallery (or any configured repository) for available modules, without installing anything.
Find-Module -Name "Az"Version Name Repository Description
------- ---- ---------- -----------
16.3.0 Az PSGallery Microsoft Azure PowerShell - Cmdlets to manage r...where -Name specifies the module name to search for and supports wildcards (e.g., "Az*").
Searching by Keyword
Find-Module -Name "*json*"Version Name Repository Description
------- ---- ---------- -----------
1.0.2.201 newtonsoft.json PSGallery Serialize/Deserialize Json using Newtonsoft.json
1.0.29 GripDevJsonSchemaValidator PSGallery A Powershell module for running Newtonsoft schem...
...Inspecting Before Installing
$module = Find-Module -Name "PSScriptAnalyzer" -Repository "PSGallery"
$module | Select-Object -Property Name, Version, Descriptionwhere:
Find-Modulequeries registered package repositories for modules matching name or keyword criteria without downloading them.-Repositorytargets a specific registered repository (e.g.,PSGallery).
Installing Modules with Install-Module
The Install-Module cmdlet downloads a module from a repository and installs it locally.
Install-Module -Name "Az" -Scope CurrentUserwhere:
-Nameis the name of the module to install.-Scopedetermines where the module is installed:CurrentUserorAllUsers.
Complete Search and Install Example
$module = Find-Module -Name "PSScriptAnalyzer" -Repository "PSGallery"
$module | Select-Object -Property Name, Version, Description
Install-Module -Name "PSScriptAnalyzer" -Scope CurrentUser -Forcewhere:
Install-Moduledownloads and installs the module package and its required dependencies.-Scopecontrols whether the module is installed for only the active user account or all system users.-Forcesuppresses interactive security confirmation prompts and overrides minor version conflicts.
./search-and-install.ps1Name Version Description
---- ------- -----------
PSScriptAnalyzer 1.25.0 PSScriptAnalyzer provides script analysis and checks for potential code defects in the script…Installation Scopes: CurrentUser vs AllUsers
The -Scope parameter dictates file placement and required privileges when running Install-Module:
| Scope | Windows Path | Linux / macOS Path | Admin Rights Required |
|---|---|---|---|
CurrentUser |
$HOME\Documents\PowerShell\Modules |
~/.local/share/powershell/Modules |
No |
AllUsers |
$env:ProgramFiles\PowerShell\Modules |
/usr/local/share/powershell/Modules |
Yes |
Install-Module -Name "posh-git" -Scope CurrentUser -Repository "PSGallery"
(Get-Module -ListAvailable -Name "posh-git").Pathwhere:
-Scope CurrentUserinstalls the module into the current user's profile directory and does not require administrative elevation.-Scope AllUsersinstalls the module into a global system directory shared by every local user account and requires an elevated administrator session.
./install-scope-demo.ps1C:\Users\Admin\Documents\PowerShell\Modules\posh-git\1.1.0\posh-git.psd1Trusting a Repository
The first time you install from the PowerShell Gallery, you may be prompted to confirm trust, since it's registered as an untrusted repository by default.
Install-Module -Name "Az" -Scope CurrentUser -Repository PSGalleryUntrusted repository
You are installing the modules from an untrusted repository...
Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):where -Repository explicitly specifies the source repository to install from.
To permanently mark the Gallery as trusted and avoid future prompts:
Set-PSRepository -Name "PSGallery" -InstallationPolicy TrustedUpdating Modules with Update-Module
The Update-Module cmdlet checks the repository from which a module was originally installed, determines whether a newer version is available, and installs the update.
Update-Module -Name "Az"where -Name is the name of the installed module to update.
Checking Installed Modules
Get-InstalledModuleVersion Name Repository Description
------- ---- ---------- -----------
11.2.0 Az PSGallery Azure Resource Manager module...Update with Version Verification
$before = (Get-Module -ListAvailable -Name "PSScriptAnalyzer").Version
Update-Module -Name "PSScriptAnalyzer" -AcceptLicense
$after = (Get-Module -ListAvailable -Name "PSScriptAnalyzer").Version
[PSCustomObject]@{
InitialVersion = $before
InstalledVersions = ($after -join ", ")
}where:
Update-Modulequeries the source repository and pulls down the highest release greater than the currently installed version.-AcceptLicenseautomatically accepts end-user license agreements required by select proprietary or third-party packages.Get-Module -ListAvailablecatalogs all side-by-side versions stored on the local disk.
./update-modules.ps1InitialVersion InstalledVersions
-------------- -----------------
1.22.0 1.22.0, 1.23.0PowerShellGet vs PSResourceGet
PowerShellGet is the original module management system (v2.x, built into Windows PowerShell 5.1). PSResourceGet (formerly PowerShellGet v3) is its modern replacement, offering faster performance and clearer cmdlet naming. Beginning with PowerShell 7.4, Microsoft replaced the legacy PowerShellGet (v2) with Microsoft.PowerShell.PSResourceGet.
PSResourceGet is written from scratch in C# and interacts directly with NuGet v3 APIs without relying on the legacy PackageManagement (OneGet) framework, resulting in significantly faster search and download speeds.
| Feature / Task | Legacy PowerShellGet (v2) |
Modern PSResourceGet |
|---|---|---|
| Search Module | Find-Module -Name <Name> |
Find-PSResource -Name <Name> |
| Install Module | Install-Module -Name <Name> |
Install-PSResource -Name <Name> |
| Update Module | Update-Module -Name <Name> |
Update-PSResource -Name <Name> |
| Save Offline | Save-Module -Name <Name> |
Save-PSResource -Name <Name> |
| Underlying Engine | PackageManagement / PowerShell scripts | Compiled C# library using NuGet v3 API |
| Performance | Slow repository queries | High-speed concurrent downloads |
| Default in | Windows PowerShell 5.1, PS7 (older versions) | PowerShell 7.4+ |
Install-PSResource -Name "Terminal-Icons" -Scope CurrentUser -TrustRepositorywhere:
Install-PSResourceis the modern cmdlet designed for high-throughput package acquisition.-TrustRepositoryinstructs the command to trust the source repository without prompting.
./psresourceget-demo.ps1Practical Usage: Bootstrapping Required Modules in a Script
A common pattern in automation scripts is to check for a required module and install it automatically if missing.
param(
[string]$ModuleName,
[string]$MinimumVersion = "0.0"
)
$installed = Get-Module -Name $ModuleName -ListAvailable |
Sort-Object Version -Descending |
Select-Object -First 1
if (-not $installed -or $installed.Version -lt [version]$MinimumVersion) {
Write-Output "Installing $ModuleName (minimum version $MinimumVersion)..."
Install-Module -Name $ModuleName -MinimumVersion $MinimumVersion -Scope CurrentUser -Force
} else {
Write-Output "$ModuleName v$($installed.Version) already satisfies requirement."
}
Import-Module -Name $ModuleName -MinimumVersion $MinimumVersionwhere:
$MinimumVersionis the lowest acceptable version of the module.-MinimumVersiononInstall-Module/Import-Moduleensures the installed/imported version meets the requirement.-Forcesuppresses trust prompts for unattended execution.
./ensure-module.ps1 -ModuleName "Az" -MinimumVersion "10.0.0"Installing Az (minimum version 10.0.0)...Practical Administration: Saving Modules for Offline / Air-Gapped Systems
Production servers often lack outbound internet access to reach the PowerShell Gallery. Administrators can download module assets onto an internet-connected staging machine using Save-Module (or Save-PSResource) and transfer them to isolated systems via an internal file share.
$exportPath = "C:\OfflineModules"
if (-not (Test-Path -Path $exportPath)) {
New-Item -Path $exportPath -ItemType Directory | Out-Null
}
Save-Module -Name "Microsoft.PowerShell.SecretManagement" `
-Path $exportPath `
-Repository "PSGallery" `
-AcceptLicense
Get-ChildItem -Path $exportPath -Directorywhere:
Save-Moduledownloads the module source files directly into a targeted folder without installing or loading them into$env:PSModulePath.-Pathspecifies the local staging folder where module assets will be extracted.Test-Pathchecks for existing filesystem directories before initiating the download.
./save-module-offline.ps1 Directory: C:\OfflineModules
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/31/2026 11:15 AM Microsoft.PowerShell.SecretManagement