Tag Archives: Version Comparison

Windows_PowerShell_icon

Dealing with multi numbered versions in powershell.

Windows_PowerShell_iconSo here’s a quick little blog about something i discovered in powershell while googling today.

Lots of vendors like to use version numbers including Major.Minor.Build.Revision.

An example of a vendor I was dealing with recently was Citrix themselves.

versionexample

The problem is, in powershell, it’s not that easy to take a string (text) representative of these, split it up then label it yourself. you’re splitting, taking objects in an array, assigning them values… nasty.

string

Did you know .Net has a native ability to do this?

Introducing system.version

Now with system.version, it’s very easy to do comparisons! Just cast your string into a [system.version] as below:

version

 

After that, just compare the major, minor, build or revision at will!

example2

 

Happy version comparing!