Skip to content

Installing PowerShell Modules

How to find, install, update, and manage PowerShell modules from the PowerShell Gallery using Find-Module, Install-Module, and Update-Module cmdlets.

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.

Consolepowershell
Find-Module -Name "Az"
Outputplaintext
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

Consolepowershell
Find-Module -Name "*json*"
Outputplaintext
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

search-and-install.ps1powershell
$module = Find-Module -Name "PSScriptAnalyzer" -Repository "PSGallery"

$module | Select-Object -Property Name, Version, Description

where:

  • Find-Module queries registered package repositories for modules matching name or keyword criteria without downloading them.
  • -Repository targets 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.

Consolepowershell
Install-Module -Name "Az" -Scope CurrentUser

where:

  • -Name is the name of the module to install.
  • -Scope determines where the module is installed: CurrentUser or AllUsers.

Complete Search and Install Example

search-and-install.ps1powershell
$module = Find-Module -Name "PSScriptAnalyzer" -Repository "PSGallery"

$module | Select-Object -Property Name, Version, Description

Install-Module -Name "PSScriptAnalyzer" -Scope CurrentUser -Force

where:

  • Install-Module downloads and installs the module package and its required dependencies.
  • -Scope controls whether the module is installed for only the active user account or all system users.
  • -Force suppresses interactive security confirmation prompts and overrides minor version conflicts.
Consolepowershell
./search-and-install.ps1
Outputplaintext
Name             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-scope-demo.ps1powershell
Install-Module -Name "posh-git" -Scope CurrentUser -Repository "PSGallery"

(Get-Module -ListAvailable -Name "posh-git").Path

where:

  • -Scope CurrentUser installs the module into the current user's profile directory and does not require administrative elevation.
  • -Scope AllUsers installs the module into a global system directory shared by every local user account and requires an elevated administrator session.
Consolepowershell
./install-scope-demo.ps1
Outputplaintext
C:\Users\Admin\Documents\PowerShell\Modules\posh-git\1.1.0\posh-git.psd1

Trusting 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.

Consolepowershell
Install-Module -Name "Az" -Scope CurrentUser -Repository PSGallery
Outputplaintext
Untrusted 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 Trusted

Updating 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.

Consolepowershell
Update-Module -Name "Az"

where -Name is the name of the installed module to update.

Checking Installed Modules

Consolepowershell
Get-InstalledModule
Outputplaintext
Version    Name    Repository    Description
-------    ----    ----------    -----------
11.2.0     Az      PSGallery     Azure Resource Manager module...

Update with Version Verification

update-modules.ps1powershell
$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-Module queries the source repository and pulls down the highest release greater than the currently installed version.
  • -AcceptLicense automatically accepts end-user license agreements required by select proprietary or third-party packages.
  • Get-Module -ListAvailable catalogs all side-by-side versions stored on the local disk.
Consolepowershell
./update-modules.ps1
Outputplaintext
InitialVersion InstalledVersions
-------------- -----------------
1.22.0         1.22.0, 1.23.0

PowerShellGet 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+
psresourceget-demo.ps1powershell
Install-PSResource -Name "Terminal-Icons" -Scope CurrentUser -TrustRepository

where:

  • Install-PSResource is the modern cmdlet designed for high-throughput package acquisition.
  • -TrustRepository instructs the command to trust the source repository without prompting.
Consolepowershell
./psresourceget-demo.ps1

Practical 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.

ensure-module.ps1powershell
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 $MinimumVersion

where:

  • $MinimumVersion is the lowest acceptable version of the module.
  • -MinimumVersion on Install-Module/Import-Module ensures the installed/imported version meets the requirement.
  • -Force suppresses trust prompts for unattended execution.
Consolepowershell
./ensure-module.ps1 -ModuleName "Az" -MinimumVersion "10.0.0"
Outputplaintext
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.

save-module-offline.ps1powershell
$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 -Directory

where:

  • Save-Module downloads the module source files directly into a targeted folder without installing or loading them into $env:PSModulePath.
  • -Path specifies the local staging folder where module assets will be extracted.
  • Test-Path checks for existing filesystem directories before initiating the download.
Consolepowershell
./save-module-offline.ps1
Outputplaintext
    Directory: C:\OfflineModules

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           3/31/2026 11:15 AM                Microsoft.PowerShell.SecretManagement
Navigation