"Robert Robelo" <Kiron@newsgroup> wrote in message
news:OMCb7WemKHA.5520@newsgroup
....
> # comparison operators can compare objects of <Version> type,
> # just pass a <Version> to their left ooperand and a <String>
> # to their right operand
> (Get-Host).Version -eq '2.0'
> (Get-Host).Version -eq '2.0.0'
> (Get-Host).Version -eq '1.9.9.9' I didn't fully understand the earlier parts of your post,
but this last is very interesting (to the actual Version problem
I am posing)....
My first thought is that comparing what is inherently a number
as a string is problematic (and I am very comfortable with how
Perl works when doing this -- it's a feature.)
But, I simply followed up on your idea and tested some of the
(more pathological) combinations, and the following things just work
(with the one exception):
(Get-Host).Version -lt '2.00'
(Get-Host).Version -ge '2.00'
(Get-Host).Version -eq '2.00'
(Get-Host).Version -eq '+2.00'
(Get-Host).Version -eq '+ 2.00' <<<<< FAILS -- that space mucks it up
(Get-Host).Version -eq '+2.00'
(Get-Host).Version -eq '-2.00'
(Get-Host).Version -eq '-2.00'
All of these give the 'correct answer as do the combos of -le, -lt, -gt
that I tried.
Even with "2 dots" this stuff seems to give sensible (i.e., correct)
answers:
(Get-Host).Version -le '2.0.0'
(Get-Host).Version -le '1.09'
(Get-Host).Version -le '1.00.9'
Also, the following conversion gives a nice answer, but
works no better than the [double] (without [string]) conversion:
[decimal][string](Get-Host).Version
--
Herb
I always learn the most when things don't work as I expect.