How to List Installed PowerShell Modules (and Check One)

To list installed modules in PowerShell, run Get-Module -ListAvailable. It searches every module folder on the PC, not just the modules loaded right now. Add -Name to look for specific modules:

Get-Module -ListAvailable -Name PSReadLine, Pester, ImportExcel |
    Sort-Object -Property Name, Version |
    Format-Table -Property Name, Version

Output in PowerShell 7:

Name        Version
----        -------
ImportExcel 7.8.9
Pester      3.4.0
PSReadLine  2.0.0
PSReadLine  2.4.5
PowerShell Get-Module -ListAvailable listing installed module versions
Installed module versions in PowerShell 7

On my PC, PowerShell 7.6 found two versions of PSReadLine. Windows PowerShell 5.1 found only the older one, and a different ImportExcel version:

Name        Version
----        -------
ImportExcel 7.8.6
Pester      3.4.0
PSReadLine  2.0.0

Each version keeps its own modules, and I’ll show why below. I ran all the examples in both, only on modules I named, so the full list from my PC isn’t shown.

How do I check if a module is installed?

Get-Module -ListAvailable -Name returns nothing when a module isn’t installed, so you can use it directly in an if:

foreach ($name in 'ImportExcel', 'Az.Accounts') {
    if (Get-Module -ListAvailable -Name $name) {
        "$name is installed"
    }
    else {
        "$name is not installed"
    }
}

Output:

ImportExcel is installed
Az.Accounts is not installed
PowerShell check if a module is installed with Get-Module -ListAvailable
Checking for two modules (Windows PowerShell 5.1)

This works for modules installed any way, whether from the PowerShell Gallery, an installer, or a folder you copied in.

Loaded modules vs installed modules

Without -ListAvailable, Get-Module shows only the modules loaded in the current session. That’s often nothing at all in a fresh session:

"Loaded now:  $((Get-Module).Name -join ', ')"

Import-Module -Name ImportExcel
"After import: $((Get-Module).Name -join ', ')"

Output:

Loaded now:
After import: ImportExcel, Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility

PowerShell loads a module automatically the first time you use one of its commands, which is why the list grew. So an empty Get-Module result doesn’t mean a module is missing.

Find the newest version of a module

You can have several versions of one module side by side. Group them by name to see the newest and how many are installed:

Get-Module -ListAvailable -Name PSReadLine, ImportExcel |
    Group-Object -Property Name |
    ForEach-Object {
        $newest = $_.Group | Sort-Object -Property Version -Descending | Select-Object -First 1
        '{0,-12} newest: {1}  (versions installed: {2})' -f $_.Name, $newest.Version, $_.Count
    }

Output in PowerShell 7:

ImportExcel  newest: 7.8.9  (versions installed: 1)
PSReadLine   newest: 2.4.5  (versions installed: 2)

To require a minimum version, filter on the Version property. Compare it as a [version], not as text, so 2.10 counts as newer than 2.9:

$ok = Get-Module -ListAvailable -Name PSReadLine | Where-Object Version -ge ([version]'2.2.0')

if ($ok) { "PSReadLine $($ok[0].Version) meets the 2.2.0 minimum" } else { 'PSReadLine 2.2.0 or later is not installed' }

Output in PowerShell 7:

PSReadLine 2.4.5 meets the 2.2.0 minimum

The same script in Windows PowerShell 5.1 printed “PSReadLine 2.2.0 or later is not installed”, because 5.1 only had version 2.0.0.

Why a module shows up in PowerShell 7 but not 5.1

The SqlServer module is installed only for PowerShell 7 on my PC. PowerShell 7 finds it, and Windows PowerShell 5.1 returns nothing:

Get-Module -ListAvailable -Name SqlServer | Select-Object -Property Name, Version

Output in PowerShell 7:

Name      Version
----      -------
SqlServer 22.4.5.1
Module installed for PowerShell 7 not found by Get-Module in Windows PowerShell 5.1
The same command in Windows PowerShell 5.1 finds nothing

The reason is $env:PSModulePath, the list of folders PowerShell searches. Here’s PowerShell 7’s list, with my user name replaced:

$env:PSModulePath -split ';'

Output in PowerShell 7:

C:\Users\alice\OneDrive\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\windowsapps\microsoft.powershell_7.6.6.0_x64__8wekyb3d8bbwe\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files\SharePoint Online Management Shell\

And Windows PowerShell 5.1’s:

C:\Users\alice\OneDrive\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files\SharePoint Online Management Shell\

PowerShell 7 also searches the Windows PowerShell folders, so it can use most 5.1 modules. But 5.1 never looks in the PowerShell 7 folders. Install a module from each version you use, or into C:\Program Files\WindowsPowerShell\Modules (as an administrator) if both should see it.

PowerShell 7 hides Windows-only modules

Going the other way, PowerShell 7 skips system modules that aren’t marked as compatible with it. -SkipEditionCheck shows them:

"Default:           $((Get-Module -ListAvailable).Count)"
"-SkipEditionCheck: $((Get-Module -ListAvailable -SkipEditionCheck).Count)"

Output in PowerShell 7:

Default:           88
-SkipEditionCheck: 117

The extra ones are Windows PowerShell system modules like AppLocker. Many still work in PowerShell 7 through its Windows compatibility feature, but they aren’t listed by default.

List modules installed from the PowerShell Gallery

Get-InstalledModule lists only modules installed with Install-Module, and it shows where each came from:

Get-InstalledModule -Name ImportExcel | Select-Object -Property Name, Version, Repository

Output in PowerShell 7:

Name        Version Repository
----        ------- ----------
ImportExcel 7.8.9   PSGallery

It works in Windows PowerShell 5.1 too. PowerShell 7.4 and later also include Get-InstalledPSResource, the newer command from PSResourceGet:

Get-InstalledPSResource -Name ImportExcel | Select-Object -Property Name, Version, Repository

Output in PowerShell 7:

Name        Version Repository
----        ------- ----------
ImportExcel 7.8.9   PSGallery

Modules that came with Windows or another installer don’t appear in either list, so use Get-Module -ListAvailable when you need to know whether a module is present at all.

Install a module only if it’s missing

Scripts that need a module can check for it, install it when it’s missing, and then import it:

$name = 'ImportExcel'

if (-not (Get-Module -ListAvailable -Name $name)) {
    Install-Module -Name $name -Scope CurrentUser -Repository PSGallery
}
Import-Module -Name $name
"Ready: $name $((Get-Module -Name $name).Version)"

Output in PowerShell 7:

Ready: ImportExcel 7.8.9

On my PC the module was already there, so the script skipped Install-Module and just imported it. On a new PC, Install-Module may ask you to trust the PowerShell Gallery the first time. The Get-Module documentation covers the remaining parameters.

Frequently Asked Questions

How do I list all installed PowerShell modules?

Run Get-Module -ListAvailable. It lists every module in the folders from $env:PSModulePath, loaded or not.

How do I check if a PowerShell module is installed?

Use if (Get-Module -ListAvailable -Name ModuleName) { ... }. The command returns nothing when the module isn’t installed.

What’s the difference between Get-Module and Get-InstalledModule?

Get-Module -ListAvailable finds every module on the PC. Get-InstalledModule lists only modules installed from a repository with Install-Module.

Why can’t Windows PowerShell 5.1 see a module I installed in PowerShell 7?

Each version searches different folders. PowerShell 7 reads the 5.1 folders, but 5.1 doesn’t read PowerShell 7’s. Install the module from 5.1 too.

How do I see which version of a module is installed?

Run Get-Module -ListAvailable -Name ModuleName | Select-Object Name, Version. Several versions can be installed side by side.

You may also want to check these: