tri_94 Posted March 2, 2021 Posted March 2, 2021 Hi there I've got a script to deploy Teams MSI, it currently compares the MSI version with the EXE version installed on the pc and if they don't match will uninstall and then reinstall the correct version. Just trying to tidy up the script really. problem i've got is the exe has both file version and product version. Get-item returns product version. $LocalVersion = (Get-Item "C:\Program Files (x86)\Teams Installer\Teams.exe").VersionInfo.FileVersion MSi version is 1.3.0.28779 but the exe version is 1.3.00.28779 currently I use the following code if ($LocalVersion -eq "1.3.00.28779") {$LocalVersion = "1.3.0.28779" I would like to be able to just change the msi and not have to add a new if statement for every version that comes out. Using Orca i've checked to see if the version with two 00's is in the msi properties and its not. So is there a way to tell ignore the second 0 in the version number? Hope this makes sense. Thanks
spadam Posted March 10, 2021 Posted March 10, 2021 I don't understand enough about version numbers to explain the different numbers but if all you need to do is handle the 00 case I suggest using a simple function to compare versions may be a reasonably robust workaround. I don't write Powershell but something like the following: function Different-Versions($v1, $v2){ $different = $FALSE $list1 = $v1.split(".") $list2 = $v2.split(".") if ($list1.Length -ne $list2.Length){ $different = $TRUE } For($i=0;$i -lt $list1.length; $i++){ if([int]$list1[$i] -ne [int]$list2[$i]){ $different = $TRUE } } Return $different } Different-Versions "1.3.00.28779" "1.3.0.28779" Different-Versions "1.3.0.28779" "1.3.0.287790" Different-Versions "1.3.0.28779" "01.03.00.028779" N.B My limited testing suggests comparing each piece as an integer will effectively ignore any leading zeros in any part of the version number - I think that's ok for this.
free780 Posted March 11, 2021 Posted March 11, 2021 Does the version work from HKLM... Uninstall key for Teams?
tri_94 Posted March 11, 2021 Author Posted March 11, 2021 Thank you for that @spadam . hadn't thought of using the type method.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now