Powershell Get-ChildItem -Filter operates differently to Where clause with same value

The Filter of FileSystem provider rather uses CMD wildcards than PowerShell wildcards. CMD wildcards are funny and not intuitive in some edge cases, mostly historically. Here is an interesting explanation: https://devblogs.microsoft.com/oldnewthing/20071217-00/?p=24143

Another gotcha to be kept in mind: ls -Filter *.txt in fact gets files like *.txt* in PowerShell sense, i.e. files with extensions starting with txt. This may be unexpected and very unpleasant in some scenarios 🙂

Leave a Comment