tags:

views:

39

answers:

2

I am trying to filter for an object that has a Title field and I want to ignore case. Is there a way to make sure case sensitivity of turned off?

| Where-Object {$_.Title -like "myString"}
+2  A: 

By default case sensitivity is off:

PS> 'test','TEST','TeSt','notest' | ? { $_ -like 'test' }
test
TEST
TeSt

From documentation:

By default, all comparison operators are case-insensitive. To make a comparison operator case-sensitive, precede the operator name with a "c". For example, the case-sensitive version of "-eq" is "-ceq". To make the case-insensitivity explicit, precede the operator with an "i". For example, the explicitly case-insensitive version of "-eq" is "ieq".

For more information run help about_comparison_operators

stej
+2  A: 

powershell is fundamentally case insensitive (e.g. "HEy" -like "hey" is TRUE). if you want to use the case sensitive version of like use -clike

Chris Ortiz