[user name] $tobe
None
[user name] $tobe -eq 0
True
therefore if you check this:
$ToBe = (Get-Variable Foo).Options
if ($ToBe -eq 0) {
"This is true, OK"
}
you'll get $true. If you check like this:
if ($ToBe) {
"And this is true, WOW"
}
you get $true too, because if ($tobe) is the same as "if ($tobe -ne
$null -or $tobe -ne $false)". But your variable is not $null, or $false:
[user name] $tobe -eq $null
False
[user name] $tobe -eq $true
False
[user name] $tobe -eq $false
False
so, I sure that it is normal.
--
WBR, Vadims Podans
PowerShell blog -
www.sysadmins.lv
"Roman Kuzmin" <nightroman@xxxxxx> rakstija zinojuma
"news:11173878-088f-4acd-b2cb-07b4c61e28df@xxxxxx"...
> Hmm, I guess your example is for int 0, not enum 0. Try this:
>
> $Foo = 0
> $ToBe = (Get-Variable Foo).Options
> if ($ToBe -eq 0) {
> "This is true, OK"
> }
> if ($ToBe) {
> "And this is true, WOW"
> }
>
> <#
> Output:
> This is true, OK
> And this is true, WOW
> #>
>