Case sensitive operators

PowerShell is more or less case insensitive so the operation in my previous post

$_.Substring(3,1) -ne "T"

will trigger on “T” or “t”

If you only want the uppercase version to fail then you can use the case sensitive version of –ne  which is –cne.

This changes the script to:

function ptest {
[ValidateScript({$_.Substring(3,1) -cne "T" })]
Write-Host "$server"

You can read more about the comparison operators in

get-help about_Comparison_Operators

Published Mon, Jul 8 2013 22:30 by RichardSiddaway
Filed under:

Leave a Comment

If you can't read this number refresh your screen
Enter the numbers above: