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
fordea Posted March 2, 2021 Posted March 2, 2021 No need to manipulate the strings, just use the [Version] type accelerator as that will take care of the redundant zeroes: $LocalVersion = [Version](Get-Item "C:\Program Files (x86)\Teams Installer\Teams.exe").VersionInfo.FileVersion You can test it yourself by comparing the two examples you gave: $firstVersion = [Version][color=#333333]"1.3.00.28779" $secondVersion = [Version][/color][color=#333333]"1.3.0.28779" $firstVersion -eq $secondVersion[/color] 1
tri_94 Posted March 3, 2021 Author Posted March 3, 2021 Thank you for that. It works as you suggested.
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