How to Programmatically Detect Installed Windows Management Framework (WMF) Version via PowerShell and Registry


1 views

For system administrators and developers working with Windows automation, determining the installed Windows Management Framework (WMF) version is crucial for compatibility testing and deployment planning. However, Microsoft doesn't provide a straightforward method to query this information, leading to widespread confusion in the admin community.

While not a direct 1:1 mapping, PowerShell version often corresponds to the WMF release. Use this command:


$PSVersionTable.PSVersion

Sample output for WMF 5.1:


Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  592

Caveat: This shows PowerShell's version, not WMF's. They frequently match but aren't guaranteed to be identical.

The WS-Management stack version provides closer correlation:


$PSVersionTable.WSManStackVersion

This typically returns values like 3.0 for WMF 3.0 or 3.1.1 for WMF 5.1.

The definitive method checks registry values installed by WMF updates:


Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine' | 
    Where-Object {$_.Property -eq 'PowerShellVersion'} | 
    Get-ItemProperty

Alternatively for systems with multiple WMF versions:


Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\PowerShell\*\PowerShellEngine' -Name PowerShellVersion -ErrorAction SilentlyContinue
WMF Version Registry Path
WMF 5.1 HKLM\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine
WMF 5.0 HKLM\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine
WMF 4.0 HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine
WMF 3.0 HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine

For scanning multiple servers, use this advanced function:


function Get-WMFVersion {
    [CmdletBinding()]
    param (
        [string[]]$ComputerName = $env:COMPUTERNAME
    )
    
    $result = @()
    foreach ($computer in $ComputerName) {
        try {
            $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer)
            $enginePath = $reg.OpenSubKey('SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine')
            
            if ($null -eq $enginePath) {
                $enginePath = $reg.OpenSubKey('SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine')
            }

            $version = $enginePath.GetValue('PowerShellVersion')
            
            $result += [PSCustomObject]@{
                ComputerName = $computer
                WMFVersion   = $version
                Source       = 'Registry'
            }
        }
        catch {
            $result += [PSCustomObject]@{
                ComputerName = $computer
                WMFVersion   = 'Detection Failed'
                Source       = 'Error'
            }
        }
    }
    return $result
}

# Usage example:
Get-WMFVersion -ComputerName 'SERVER01','SERVER02'

Windows Management Framework (WMF) is a bundle that includes PowerShell, WMI, WinRM, and other management components. When you need to verify the installed version across multiple servers, you'll find it's not exposed through conventional Windows interfaces like Programs and Features.

Here are three technical approaches to determine the exact WMF version:

# Method 1: Check PowerShell version (common proxy for WMF)
$PSVersionTable.PSVersion

# Method 2: Examine WS-Management stack version
$PSVersionTable.WSManStackVersion

# Method 3: Registry-based detection
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine' | 
    ForEach-Object { Get-ItemProperty $_.PSPath } | 
    Select-Object PowerShellVersion

Here's how WMF versions correspond to PowerShell releases:

WMF Version PowerShell Version Included OS Versions
WMF 5.1 5.1.xxxxx Windows 10/Server 2016+
WMF 5.0 5.0.10586 Optional update
WMF 4.0 4.0 Windows 8.1/Server 2012 R2
WMF 3.0 3.0 Windows 7 SP1/Server 2008 R2 SP1

For checking across multiple machines in a domain environment:

# Remote WMF detection script
$computers = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name
$results = Invoke-Command -ComputerName $computers -ScriptBlock {
    [PSCustomObject]@{
        ComputerName = $env:COMPUTERNAME
        WMFVersion = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine').PowerShellVersion
        PSVersion = $PSVersionTable.PSVersion
    }
}
$results | Export-Csv -Path "WMF_Inventory.csv" -NoTypeInformation

When version detection fails:

  • Check if PowerShell remoting is enabled (WinRM quickconfig)
  • Verify registry permissions on target machines
  • For legacy systems (WMF 2.0), check HKLM\SOFTWARE\Microsoft\PowerShell\1
  • Consider using WMI fallback: Get-WmiObject -Namespace root\cimv2 -Class Win32_Product | Where-Object Name -like "*Windows Management Framework*"

Critical WMF files and their typical locations:

# Check core assembly versions
(Get-Item "$env:windir\System32\WindowsPowerShell\v1.0\powershell.exe").VersionInfo.FileVersion
(Get-Item "$env:windir\System32\wbem\wmiprvse.exe").VersionInfo.FileVersion