Given:
PowerShell 5.1
Can someone help me extract metadata from an msi file?
I've tried the following, but no comments property.
$filePath = "C:\Users\user1\source\repos\PRACTICE\WpfApp1\SetupProject1\bin\Debug\SetupProject1.msi"
$fileProperties = Get-ItemProperty -Path $filePath
$fileProperties | Format-List *
You can try using Shell.Application
COM object to extract the metadata, I don't know of a way to extract just Comments
, but there is a way to extract all the metadata from it into an ordered dictionary.
# using PowerShell msi for the example
$path = 'path\to\PowerShell-7.5.0-win-x86.msi'
$shell = New-Object -ComObject Shell.Application
$dir = $shell.NameSpace([System.IO.Path]::GetDirectoryName($path))
$item = $dir.ParseName([System.IO.Path]::GetFileName($path))
$metadata = [ordered]@{}
for ($id = $nullCounter = 0; $nullCounter -lt 10; $id++) {
$key = $dir.GetDetailsOf($null, $id)
$value = $dir.GetDetailsOf($item, $id)
if ($key -and $value) {
$metadata[$key] = $value
$nullCounter = 0
continue
}
if ($id -lt 320) { continue }
$nullCounter++
}
Then from here you should have all the file metadata in $matadata
, and assuming it had a Comments
key, you could do:
$metadata['Name'] # PowerShell-7.5.0-win-x86.msi
$metadata['Comments'] # PowerShell for every system
$metadata['Title'] # Installation Database
$metadata['Subject'] # PowerShell package
$metadata['Authors'] # Microsoft Corporation