Three comparisons in my script misbehave. With $levels = 3, 0, 7, the test if ($levels -eq 0) is never true although the array contains a zero, and at the prompt $levels -eq 7 prints 7 rather than True. After $n = Read-Host "Threshold", entering 10 makes if ($n -gt 5) false. And when I wrote if ($count > 10) out of habit, a file named 10 appeared.
How do PowerShell's comparison operators decide what to compare, and what is the safe way to write these checks?




