When you compare version strings, PowerShell will use alphanumeric algorithms, which may lead to confusing results:
'3.4.22.12' -gt '22.1.4.34'
True
You should convert the strings to a System.Version type to compare version strings right. In fact, converting the left hand value is enough because PowerShell automatically converts the right hand value to the same type:
[System.Version] '3.4.22.12' -gt '22.1.4.34'
False
ReTweet this Tip!
Posted
Sep 01 2010, 08:00 AM
by
ps1