I'm trying to compare two versions of Edge. One is updated by others, and one I must manually update. I currently have a PowerShell script which grabs both versions and emails them to me:
$Servername = $env:computername
$To2 = '******@work.com'
$InstVer=(Get-Command "C:\location 1\msedge.exe").Version
$PortVer=(Get-Command "C:\location 2\msedgedriver.exe").Version
{$smtps = 'a_mailserver.com'}
Send-MailMessage -SmtpServer $smtps -From '******@work.com' -To "$To2" -Subject "Edge browswer report from $Servername" -Body "On server $Servername, Edge version is $InstVer and Edge Driver version is $PortVer."
This works very well, except I receive too many emails. I would prefer the script to compare the two versions and tell me if there is a difference in the Major version.
If I use a line like this to compare it states they are different:
$InstVer -gt $PortVer
103.0.1264.49
103.0.1264.37
True
I found and tried the following code, which just uses hard-coded versions for comparisons:
[version]$SomeVersion='1.1.2'
[version]$OtherVersion='1.1.1.0'
$NormalizedScriptVersion = New-Object -TypeName System.Version -ArgumentList $SomeVersion.Major,$SomeVersion.Minor,$SomeVersion.Build
$NormalizedCurrentVersion = New-Object -TypeName System.Version -ArgumentList $OtherVersion.Major,$OtherVersion.Minor,$OtherVersion.Build
$NormalizedScriptVersion -gt $NormalizedCurrentVersion
Same issue though, it compares all parts, Major, Minor and Build.
I even tried removing the .Minor and .Build arguments, but PowerShell complained.
Any ideas?