Monday, October 14, 2013

PowerShell - Check if number is even or odd

Here is a simple example to demonstrate one way of testing a number to see if it is EVEN or ODD.


$NumberToTest = 11

If([bool]!($NumberToTest%2))
{
   Write-Host "$NumberToTest is EVEN"
}
Else
{
   Write-Host "$NumberToTest is ODD"
}

Cheers!

No comments:

Post a Comment