Stackers,
I am trying to get (from an MSI of Chrome Enterprise) a version number. After I download Chrome as a .MSI , I notice that I can see a number of properties. The one I want to be able to access and build an "if statement" off of is the "Comments" section.
When I try to use Get-Item and format it as a list, it says there is nothing in there and I cannot seem to identify what to do.
(Get-Item ".\Chrome.msi").VersionInfo | fl
That command returns:
How can I pull the "Comments" section and the data from it?
These properties are not stored in the System.IO.FileInfo
object returned by Get-Item
or Get-Command
. A solution would be to use the shell.application
COM object to retrieve these attributes for you:
$filePath = ".\Chrome.msi"
$parentPath = (Resolve-Path -Path (Split-Path -Path $filePath)).Path
$fileName = Split-Path -Path $filePath -Leaf
$shell = New-Object -COMObject Shell.Application
$shellFolder = $Shell.NameSpace($parentPath)
$shellFile = $ShellFolder.ParseName($fileName)
$shellFolder.GetDetailsOf($shellFile,24)
24
, is the ID of the specific property you're after so in this case it's comments needed for .GetDetailsOf(.,.)
to get that info . Luckily, I came across this issue before when I too was trying to parse for the comments. I don't recall where but, I found the solution proposed above so I will link it when I can once again find it.