Thread: -ne operator
View Single Post
Old 11-23-2008   #1 (permalink)
Simon Walsh
Guest


 
 

-ne operator

Hi

I have a script that accepts an argument from the user. There are four
possible values that I wish the user to pass to the script. I wil then take
different actions based on the argument passed.
If I do not get one of those values I want to error out. I am not really
sure how to use the the operators.

What I have so far

$Input = $args[0]
If ($Input -ne "1")
{
Write-Host "Error"
Break
}

So here I will break out if I do not get 1 as an input. I also want to error
out if I don't get 2, 3 or 4.

I have tried:
If ($Input -ne "1" -ne "2" -ne "3" -ne "4")
{
Write-Host "Error"
Break
}
but that doesn't work..

Anyone have any tips?

Thanks
Simon


My System SpecsSystem Spec