keepcalculator

06 Numbers and Powers

Get PowerShell Module Version: 4 Ways

Card No. 06·31219 · Updated · Standard formula, shown below

The calculator on this card is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

To get a PowerShell module version, use the Get-Module cmdlet with the -ListAvailable parameter, then read the Version property. For example: Get-Module -ListAvailable -Name Az | Select-Object Name, Version. This article explains four reliable methods, how to read the output, and how to handle common issues like multiple versions or modules that won’t load.

Formula

There is no arithmetic formula for retrieving a module version—it is a metadata lookup. The version number is stored in the module manifest (.psd1) or in the module binary’s assembly information. The command Get-Module -ListAvailable -Name <ModuleName> reads that metadata and outputs a PSModuleInfo object. The Version property of that object holds the version as a System.Version type, which supports major.minor.build.revision (e.g., 5.1.0.0).

Worked Example

Suppose you want the version of the Az module (the default in the calculator above). Run:

Get-Module -ListAvailable -Name Az | Select-Object Name, Version

If the output shows Version 12.1.0, that is the version. The calculator above simply returns 0 because it is a placeholder—the actual lookup requires PowerShell. For a module that is currently imported, use Get-Module -Name Az (without -ListAvailable) to see the loaded version. Both commands output a Version property you can read directly.

Why You Need the Module Version

Knowing the exact version matters for several practical reasons:

  • Compatibility: Scripts written for one version may break with another. For instance, a function that existed in version 2.0 might be removed in 3.0.
  • Bug fixes and features: If you are troubleshooting an issue, the fix may only be in a newer version. Conversely, a known regression might mean you need to downgrade.
  • Documentation: When asking for help online, including the version helps others reproduce your problem.
  • Automation: In CI/CD pipelines, you may need to verify the module version before running a script.

Method 1: Get-Module -ListAvailable (Recommended)

This is the most reliable way to see what is installed, even if the module is not currently loaded. The command scans all directories in the $env:PSModulePath and returns every version found.

Get-Module -ListAvailable -Name Az

To see only the version number as a string, use:

(Get-Module -ListAvailable -Name Az).Version.ToString()

If you have multiple versions installed, this returns an array. You can sort them to find the latest:

Get-Module -ListAvailable -Name Az | Sort-Object Version -Descending | Select-Object -First 1

Method 2: Get-Module for Loaded Modules

If the module is already imported into your session, Get-Module -Name Az (without -ListAvailable) shows the loaded version. This is faster but only shows what is currently in memory. If you have multiple versions installed, only the one that was imported appears.

Get-Module -Name Az | Select-Object Name, Version

Method 3: Using the Module Manifest

Every module has a manifest file (.psd1) that contains a ModuleVersion key. You can read it directly with Test-ModuleManifest:

Test-ModuleManifest -Path "C:\Program Files\WindowsPowerShell\Modules\Az\12.1.0\Az.psd1" | Select-Object Name, Version

This is useful if you need to verify the exact path or if Get-Module is not finding the module due to path issues.

Method 4: Using the Gallery (for Online Modules)

If you want to know the latest version available online (not what is installed), use the PowerShellGet cmdlet:

Find-Module -Name Az | Select-Object Name, Version

This queries the PowerShell Gallery. Note that this requires internet access and the PowerShellGet module (installed by default in PowerShell 5.1 and later).

Common Problems and How to Fix Them

  • Multiple versions installed: Get-Module -ListAvailable returns all of them. Use Sort-Object Version -Descending | Select-Object -First 1 to get the newest.
  • Module not found: The module may not be in a path listed in $env:PSModulePath. Check the path or install the module with Install-Module.
  • Version shows 0.0 or blank: This can happen if the module manifest is malformed or if the module is a script module without a version. Try Test-ModuleManifest to see the error.
  • PowerShell Core vs Windows PowerShell: Modules are installed per PowerShell edition. A module installed for Windows PowerShell 5.1 may not appear in PowerShell 7. Check the $PSVersionTable and the module path.

Frequently Asked Questions

How do I get the version of a module I just installed?

After running Install-Module -Name Az, run Get-Module -ListAvailable -Name Az to see the installed version. If you have already imported it, Get-Module -Name Az works too.

Why does Get-Module show two versions of the same module?

You likely have the module installed in two different directories, such as the system-wide Program Files and the user-specific Documents folder. PowerShell loads the first one it finds in $env:PSModulePath order. Use -ListAvailable to see all.

Can I get the version without importing the module?

Yes, use Get-Module -ListAvailable -Name <Name>. It reads the module metadata without loading it into memory.

How do I check the version of a module in a script?

Store the result in a variable and compare it. For example: $ver = (Get-Module -ListAvailable -Name Az).Version; if ($ver -lt [version]'12.0.0') { Write-Warning 'Update Az' }.

What is the difference between Version and PSVersion?

Version is the module’s own version. PSVersion (or PowerShellVersion in the manifest) is the minimum PowerShell version the module supports. They are independent.

Does Get-Module work in PowerShell Core (7+)?

Yes, Get-Module is available in both Windows PowerShell 5.1 and PowerShell 7+. The syntax is identical.

Final Tips

Always use -ListAvailable unless you are certain the module is loaded. When writing scripts, avoid hardcoding versions; instead, check the version at runtime and fail with a clear message if it does not meet requirements. For modules from the gallery, you can also check the release notes online, but the version number is the quickest way to confirm what you are running.

Related

Formula used
in m | Module name | - | Az | 0
out v | Module version | - | 0 | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →