Reputation: 59
In order to find an installed MSI file GUID in a remote VM - I'm using the following command inside of Invoke-Command
:
Get-WmiObject Win32_Product | Where-Object {$_.Name -eq "Application Name"}
This command shows in it's output an identifier number.
I know, I should add one more thing to this command in order to get only the GUID but I don't know how...
Now, I need to compare between this GUID to a GUID of a new MSI file I got for an installation.
This mean that:
if the GUID of the new file is older - I'll do nothing
if the GUID of the new file is equal - I'll do nothing
if the GUID of the new file is newer - I'll do an upgrade OR uninstall-install process...
So, In order to compare between the installed MSI's GUID and a new MSI file's GUID:
What will be the exact PowerShell command to find the GUID of the new MSI file?
Upvotes: 1
Views: 5045
Reputation: 59
I installed a Carbon library both in the remote VM and in my pc in "C:\Program Files\WindowsPowerShell\Modules" I then execute the following Command:
[string] $newMSIProductCode = (Get-CMsi -Path "C:\appName.msi").ProductVersion
[string] $newMSIProductCodeGUID = (Get-CMsi -Path "C:\appName.msi").ProductCode.Guid
$newMSIProductCode = $newMSIProductCode -replace '\.',''
Enter-PSSession -Computer $computer -Credential $credentials
Invoke-Command -Computer $computer -Credential $credentials -ScriptBlock {
[string] $installedMSIProductCode = (Get-CProgramInstallInfo -Name "app name").DisplayVersion
$installedMSIProductCodeGUID = (Get-CProgramInstallInfo -Name "app name").ProductCode.Guid
[long] $installedMSIProductCode = $installedMSIProductCode -replace '\.',''
if ($Using:$newMSIProductCodeGUID -gt $installedR10ServerBuildProductCode)
{
//TO-DO
}
}
Upvotes: 0
Reputation: 42236
If I understand correctly you want to find the product GUID of an MSI that is not currently installed? I hope that is a correct understanding of what you ask. If you need to automatically get the product GUID from code, that is also possible. There is a full, standalone VBScript here which you can drag-and-drop an MSI file onto to retrieve the product code.
You can find the product code by opening the MSI with a suitable viewer - for example Orca
, the Microsoft SDK tool for MSI packages. If you have Visual Studio installed, try searching for Orca-x86_en-us.msi
- under Program Files (x86)
- and install it. Then find Orca in the start menu. You can also right click MSI files to open them with Orca - just select: "Edit with Orca"
. Then you can find the product GUID in the Property table.
Here is an answer on the topic of MSI viewers (several alternatives, but Orca is the best overall): How can I compare the content of two (or more) MSI files?
There is a Powershell module for MSI: https://github.com/heaths/psmsi
Links:
Upvotes: 1