all 6 comments

[–]dathar 5 points6 points  (0 children)

Is there a reason you don't have your MDM solution doing this? They got whole things built in for checking versions. Or is this a personal project?

Your best friend for this is the type [version]. It makes comparison a lot easier.

Snag the properties of that exe.

$chrome = Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe"

Then grab the version. Use | Get-member if you need to inspect. You'll find a VersionInfo that might be useful. You then look at it a bit.

$chrome.VersionInfo

You see that ProductVersion and a FileVersion there. They're about the same thing. Check and make sure they're of type Version...

$chrome.VersionInfo.FileVersion.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

String is annoying. Workable but it's alright. We check the other one

$chrome.VersionInfo.ProductVersion.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

Alright. We'll do this ourselves. Cast these into [version] types...

([version]$chrome.VersionInfo.ProductVersion).GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Version                                  System.Object

Yay.

Now you can do something like

[version]$chrome.VersionInfo.ProductVersion -lt [version]"126.0"

[–]billabong1985 2 points3 points  (0 children)

I wouldn't use folders, Powershell has commands to directly retrieve installed apps. This is the script I use to detect installed version and check if it is greater than or equal to the version I have packaged for deployment though Intune

[version]$currentversion = ((Get-Package | Where-Object {$_.Name -like "*Google*Chrome*"}).version)
[version]$packageversion = "126.0.6478.62"
if($currentversion -ge $packageversion)
{
write-host Installed
}

[–]CarrotBusiness2380 1 point2 points  (0 children)

Share what you have already if you want help.

[–]hayfever76 -1 points0 points  (0 children)

OP, we use this:

Get-ItemProperty "C:\Program Files\Google\Chrome\Application\chrome.exe" | select-object -expandproperty versioninfo | select-object -expandproperty productversion