Wednesday, 4 July 2018

Find Installed Software’s Product code and Upgrade code using PowerShell

Sometimes we may required to find installed applications product and upgrade code for maintenance purpose or any other reason. In this post, I am going to share powershell script to get product id and upgrade code of installed tool.

Find Product Code:

The below command lists all the installed software’s name and product code
get-wmiobject Win32_Product | Select-Object @{ n='Name'; e={$_.Name}}, @{n='ProductCode'; e={$_.IdentifyingNumber}}
If you know the product name, you can just run the below command to get product code for a specific application.
$productName = “Name of your product”
$info = get-wmiobject Win32_Product | Where-Object { $_.Name –eq $productName}
$productCode = $info. IdentifyingNumber
In latest powershell (Windows 10 and later), we can use the command Get-Package to retrieve installed applications.
Get-Package | Select-Object @{ n='Name'; e={$_.Name}}, @{n='ProductCode'; e={$_.Metadata["ProductCode"]}}

Find Upgrade Code:

Once you find product code from above script, you can easily find upgrade code by using product code. Replace your product code in below script and run the commands to get upgrade code.
gwmi -Query "SELECT Value FROM Win32_Property WHERE Property='UpgradeCode' AND ProductCode='{your product code}'" | Format-Table Value


No comments:

Post a Comment