Example I am following:
Get-ChildItem c:\scripts\*.* -include *.txt,*.log
https://technet.microsoft.com/en-us/library/ee176841.aspx
What gives? Why don't I get back a list of my test.txt files when I try to use include?
As a side note, what is c:\scripts\*.*
. It seems to be saying include a file with any name that has any format. But isn't that specified in the include? Anyway, more interested in why my seemingly basic code doesn't work.
From the help file (Get-Help Get-ChildItem
):
The Include parameter is effective only when either 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.
Get-ChildItem c:\pstest\*.* -include *.txt
or
Get-ChildItem c:\pstest -recurse -include *.txt
or better yet: use the -Filter
parameter instead of -Include
:
Get-ChildItem C:\pstest -Filter *.txt