PowerTip: Use PowerShell to Perform Case-Sensitive Comparison

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'


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


PS C:\>

Comments (0)

Skip to main content