Windows PowerShell Home
Get-ChildItem -Path * -Filter <filter> -Recurse should be all items that match the filter
6/17/2009 10:38:58 AM
User(s) can reproduce this bug
According to the helpfile for Get-ChildItem "-Filter" qualifies the -Path parameter
My claim is that nearly everyone will consider the following two commands identical
PS:> gci *
however when the filter, path and recurse parameters are used together only the files matching in the top level directory are returned.
How often does this happen?
Have you seen this problem before in this product?
I don't know if this issue existed previously
1) cd windows
2) gci -path * -filter *.log -recurse ## only returns the files the Windows folder matching the filter
3) gci -filter *.log -recurse ## returns the files in the top level folder and all sub-directories
I expect both 2) and 3) to return the same results.
Please fix this prior to releasing version 2
to post a comment.
Please enter a comment.
on 12/6/2011 at 9:26 PM
Closing this as external is a cop-out.
on 6/17/2009 at 12:41 PM
Here is some more details of what I believe to be at best a doc bug explaining that for Powershell unlike other Shells
an empty path
are totally different when it comes to recursion
you are both correct as not.
When one uses this
Get-ChildItem -Path * -Recurse -Filter <filter>
gci * -Recurse -Filter <filter>
this cmdlet will call the providers GetChildNames method
protected virtual void GetChildNames (
ReturnContainers returnContainers <<< This is set to
its a no win situation if it were set to ReturnAllContainers then the filter
would be ignored. Set as it is it will not recurse.
If one does this which in my opinion should give the same results
Get-ChildItem -Recurse -Filter <filter>
gci -Recurse -Filter <filter>
this cmdlet will call the providers GetChildItems method
protected virtual void GetChildItems (
in this case there is a flag so the provider must return everything matching
the filter in all directories.
In either case the cmdlet Get-ChildItem is not implementing the recursion
merely passing on the flag to the provider.
There's not a really good solution. Personally I think GetChildNames should
have had a parameter for recursion so that Get-ChildItems could have passed
I don't know of another OS which doesn't treat both an empty path and an
asterics as the same exact semantics.
As it stands now I don't know what can be done other than making the
documentation clearly state this. What I would really like to see is the
Powershell group fix/extend (in my opinion) GetFileNames to have an
additional parameter for recursion.
to post a workaround.
Please enter a workaround.
© 2014 Microsoft