- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to retrieve the MSI package product code using PowerShell?
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{$_.name - eq "7-Zip 19.00 (x64 edition)"} PS C:\> $product.IdentifyingNumber
Output
To get the output from the remote computer, just specify the -ComputerName parameter.
$product = Get-WmiObject win32_product -ComputerName TestMachine1, Testmachine2 | where{$_.name -eq "7-Zip 19.00 (x64 edition)"} $product.IdentifyingNumber
Advertisements