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!

Related Posts

New Module: Creating an RDP file password with Pow... Here's something that is surprisingly tricky to automate in this day and age. Creating a password and storing it in an RDP file. I'm not here to debat...
Accurately checking the Citrix PVS “cache in... Citrix Provisioning services "Cache in RAM, overflow to disk", even with it's challenges is something I've always felt was a great idea, hell, I fores...
Adding a list of Authorised files to RES Workspace... This is just a quick article on how to search for exe's recursively in a specific path and add them to an RES Workspace Manager building block to be i...

Leave a Reply