Reputation: 3109
I've got 3 ps1 files under d:
-a--- 6/19/2015 2:52 PM 104 Untitled1.ps1
-a--- 6/19/2015 2:56 PM 204 Untitled2.ps1
-a--- 6/16/2015 1:17 PM 3073 Untitled3.ps1
I can use get-childitem to retrive them:
get-childitem d:\
But this fails:
get-childitem d:\ -Force -Include *.ps1
This command doesn't show any thing. Why? I just want to filter out .ps1 file. Anything wrong with my command?
Upvotes: 2
Views: 2275
Reputation: 58931
The Include parameter is effective only when the command includes the Recurse parameter or the path leads to the contents of a directory, such as C:\Windows*, where the wildcard character specifies the contents of the C:\Windows directory.
Source: https://technet.microsoft.com/en-us/library/hh849800.aspx
You can use the -Filter parameter instead:
Get-ChildItem -Path 'd:\' -Filter '*.ps1'
Or if you need to filter multiple extensions, use the wildcard character:
Get-ChildItem -Path 'd:\*' -Include '*.ps1', '*.bat'
Upvotes: 5