Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use PowerShell to Perform Case-Sensitive Comparison

$
0
0

Summary: Learn how to perform a case-sensitive comparison in Windows PowerShell.

Hey, Scripting Guy! Question I need to compare two strings while taking case sensitivity into account. I try using -eq, but it does not work.
            How can I use Windows PowerShell to perform a case-sensitive comparison?

Hey, Scripting Guy! Answer Use the -ceq operator instead of -eq. Here are two examples that compare the results of -eq and -ceq:

PS C:\> 'scripting guys' -eq 'Scripting Guys'

True

PS C:\> 'scripting guys' -ceq 'Scripting Guys'

False

PS C:\>


Viewing all articles
Browse latest Browse all 3333

Trending Articles