Finding MSI Product Codes (Part 2)

by Oct 19, 2022

On Windows 10 and better, finding MSI packages and their product codes no longer requires WMI queries. Instead, you can use Get-Package:

Get-Package | 
Select-Object -Property Name, @{
    Name='ProductCode'
    Expression={
        $code = $_.Metadata["ProductCode"]
        if ([string]::IsNullOrWhiteSpace($code) -eq $false)
        {
            $code
        }
        else
        {
            'N/A'
        }
    }
} |
Format-List

Twitter This Tip! ReTweet this Tip!