PowerTip: Use PowerShell to Perform Case-Sensitive Comparison
Summary: Learn how to perform a case-sensitive comparison in Windows PowerShell.
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?
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'