How to do a case-sensitive file search with PowerShell?
try piping Get-Childitem
to Where-Object
like this:
Get-Childitem -Path C:\ | Where-Object {$_.what_you_want_to_filter -match "REGEX"}
here it is with like syntax (thanks FLGMwt)
Get-Childitem -Path C:\ | Where-Object {$_.Name -clike "CAPS*"}
The FileSystem provider's filter is not case sensitive, but you can pipe it to:
Where{-NOT ($_.BaseName -cmatch "[a-z]")}
That will find files that do not contain lower case letters. If you match against upper case it will work for any file that has at least 1 capital letter, and can still include lower case.
You can use regex option for this
| Where{ $_.BaseName -match "(?-i)^[A-Z]+") }
Or
| Where{ $_.BaseName -cmatch "^[A-Z]+"}