![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | get-childitem -include question Everyone, I was surprised by the results from this command: get-childitem c:\* -include * It looks like it recurses through subdirectories even though I didn't specify -recurse. If I use: get-childitem c:\* -include *.log It only outputs *.log files in c:\. The second command works as expected, but the first one doesn't. Am I missing something obvious? -- Bill Stewart |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: get-childitem -include question Bill Stewart wrote:
get-childitem c:\* -include $NULL -- Bill Stewart | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) |
| Guest | Re: get-childitem -include question Hi Bill, Notice that it doesn't do a full recurse, it only lists one level of each directory. Now, why it happens? Take a look at the help for the -include parameter, it can take list/dir multiple paths (e.g. <string[]>). Because you specified the contents of the directory (*) which means all items + the include parameter includes all items too (*) then it performs a dir for each directory path it finds: -include <string[]> Retrieves only the specified items. The value of this parameter qualifies the Path parameter. Enter a path elem ent or pattern, such as "*.txt". Wildcards are permitted. The Include parameter is effective only when the command includes the Recurse parameter or the path leads to th e contents of a directory, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\ Windows directory. --- Shay Levy Windows PowerShell MVP blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic BS> Everyone, BS> BS> I was surprised by the results from this command: BS> BS> get-childitem c:\* -include * BS> BS> It looks like it recurses through subdirectories even though I BS> didn't specify -recurse. If I use: BS> BS> get-childitem c:\* -include *.log BS> BS> It only outputs *.log files in c:\. BS> BS> The second command works as expected, but the first one doesn't. BS> BS> Am I missing something obvious? BS> |
My System Specs![]() |
| | #4 (permalink) | ||||||||||||
| Guest | Re: get-childitem -include question Shay Levy [MVP] wrote:
directory structure: C:\--+--dir1 | +--dir2--+--dir2a | | | +--dir2b | +--dir3 If I write get-childitem c:\* -include * the cmdlet will retrieve all items from C:\, including its subdirectories (dir1, dir2, and dir3). Since dir1, dir2, and dir3 are directories, their contents will be retrieved as well, as if I wrote: get-childitem c:\dir1 get-childitem c:\dir2 get-childitem c:\dir3 It seems to me that this is another example where get-childitem needs container qualifiers (e.g., retrieve only non-containers). I've added my vote on Connect. -- Bill Stewart | ||||||||||||
My System Specs![]() | |||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||
| Guest | Re: get-childitem -include question Yes, you can get the directory list using: PS > dir c:\* -include * | select directory -unique Notice that directories that has no files in it won't show up. --- Shay Levy Windows PowerShell MVP blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic BS> Shay Levy [MVP] wrote: BS>
BS> following directory structure: BS> BS> C:\--+--dir1 BS> | BS> +--dir2--+--dir2a BS> | | BS> | +--dir2b BS> | BS> +--dir3 BS> If I write BS> BS> get-childitem c:\* -include * BS> BS> the cmdlet will retrieve all items from C:\, including its BS> subdirectories (dir1, dir2, and dir3). Since dir1, dir2, and dir3 BS> are directories, their contents will be retrieved as well, as if I BS> wrote: BS> BS> get-childitem c:\dir1 BS> get-childitem c:\dir2 BS> get-childitem c:\dir3 BS> It seems to me that this is another example where get-childitem BS> needs container qualifiers (e.g., retrieve only non-containers). BS> I've added my vote on Connect. BS> | ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| understanding get-childitem -include | Leo Tohill | PowerShell | 2 | 05-19-2008 01:46 PM |
| Get-ChildItem -include leaks memory | Staffan Gustafsson | PowerShell | 9 | 06-05-2007 03:27 PM |
| Get-ChildItem -Recurse -Include pattern question... | Peter Birkholm-Buch | PowerShell | 1 | 02-26-2007 08:07 AM |
| Weird behavior using -Include switch on Get-ChildItem on local dir | Don Dally | PowerShell | 5 | 12-22-2006 01:20 PM |
| About get-childitem -include parameter | applepwc | PowerShell | 6 | 05-25-2006 11:58 AM |