powershell idiosynchrosies
January 4, 2008 Leave a comment
issues with dir / get-childitem with -include and -recurse
So, I have a directory “c:\utils” that shows this when I ‘dir’:
Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 02/01/2008 17:03 480 autoruns.lnk -a--- 02/01/2008 17:04 475 Console.exe.lnk -a--- 02/01/2008 17:05 475 procexp.exe.lnk -a--- 03/01/2008 16:49 621 Regulator.lnk -a--- 02/01/2008 17:06 643 runemacs.exe.lnk -a--- 02/01/2008 17:05 475 Tcpview.exe.lnk -a--- 02/01/2008 17:05 475 WinDiff.Exe.lnk
I want to a listing which just shows the files with extensions .exe.lnk, ie:
Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 02/01/2008 17:04 475 Console.exe.lnk -a--- 02/01/2008 17:05 475 procexp.exe.lnk -a--- 02/01/2008 17:06 643 runemacs.exe.lnk -a--- 02/01/2008 17:05 475 Tcpview.exe.lnk -a--- 02/01/2008 17:05 475 WinDiff.Exe.lnk
These commands work and return what I want:
dir *.exe.lnk dir -filter *.exe.lnk dir * -include *.exe.lnk dir -include *.exe.lnk -recurse
These commands return nothing:
dir -include *.exe.lnk dir . -include *.exe.lnk dir c:\utils -include *.exe.lnk
unless there’s a bug here it just seems too unintuitive and overly-pedantic.