header image

Case sensitive operators

Posted by: | July 8, 2013 | No Comment |

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

under: PowerShell Basics