PowerShell for Windows Admins

Jul 8 2013   3:31PM GMT

Case sensitive operators



Posted by: Richard Siddaway
Tags:
PowerShell

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 {
[CmdletBinding()]
param(
[ValidateScript({$_.Substring(3,1) -cne "T" })]
[string]$server
)
Write-Host “$server”
}

You can read more about the comparison operators in
get-help about_Comparison_Operators

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: