How to retrieve the MSI package product code using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

You can retrieve the MSI installed packaged product code on the windows OS using PowerShell with Get-Package or Get-WmiObject command.

In this example, we will retrieve the product code of 7-zip.

Get-Package -Name '7-Zip 19.00 (x64 edition)' | fl *

You can use the tagid or mentioned properties to filter the product code.

To retrieve the package from the remote computer using the Get-Package method, use InvokeCommand.

Invoke-Command -ComputerName TestMachine -ScriptBlock{
   (Get-Package -Name '7-Zip 19.00 (x64 edition)').TagID

Another way to retrieve the product code is by using the WMI method as shown below.

PS C:\> $product = Get-WmiObject win32_product | where{$ -
eq "7-Zip 19.00 (x64 edition)"}
PS C:\> $product.IdentifyingNumber


To get the output from the remote computer, just specify the -ComputerName parameter.

$product = Get-WmiObject win32_product -ComputerName
TestMachine1, Testmachine2 | where{$ -eq "7-Zip 19.00 (x64 edition)"}
Published on 31-Aug-2021 09:59:23