if with -ne and -or operators not working in powershell
<p>The following if statements with -ne and -or operators is not working (Note I did not include the braces). $MyVariable is an integer coming in from a parameter in a function and having the if statement check the value. What I want is if <strong>$MyVariable</strong> is not equal to 16, 24 or 32 then return with error message otherwise continue. Calling the function as <strong>FunctionName 16;</strong> in the ps1 script.</p>

<p>Function is defined as follows:</p>

<pre><code>function FunctionName
{
  param([Parameter(Mandatory = $false, Position = 0)]
            [AllowNull()]
            [int]   $MyVariable,
            [Parameter(Mandatory = $false, Position = 1)]
            [bool] $MyVariable2,
            [Parameter(Mandatory = $false, Position = 2)]
            [bool] $MyVariable3);
  if (...
}
</code></pre>

<p>What am I doing wrong in the following if statements?</p>

<pre><code>if ($MyVariable -ne 16 -or $MyVariable -ne 24 -or $MyVariable -ne 32)...
if (16 -ne $MyVariable -or 24 -ne $MyVariable -or 32 -ne $MyVariable)...
if (($MyVariable -ne 16) -or ($MyVariable -ne 24) -or ($MyVariable -ne 32))...
</code></pre>