Help with the basics.

Hi There,

I’m currently going through Don’s great book ‘Powershell in a month of lunches’ and really digging into the basics to solidify my understanding of the fundamentals.

So I was digging around testing the help menu examples for Get-ChildItem and was hoping for some clarification.

-------------------------- EXAMPLE 7 -------------------------- C:\PS>get-childitem c:\windows\logs\* -include *.txt -exclude A*

This command gets the .txt files in the Logs subdirectory, except for those whose names start with the letter A. It uses the wildcard character (*) to indicate the contents of the Logs subdirectory, not the directory container. Because the command does not include the Recurse parameter, Get-ChildItem does not include the contents of the current directory automatically; you need to specify it.

Now on my machine (windows 7, PS ver.3) the C:\Windows\Log\ directory contains a number of subdirectories and files, but using the wildcard or excluding it make no difference to the results I receive.

get-childitem c:\windows\logs\* 
get-childitem c:\windows\logs\ 
Directory: C:\Windows\Logs

Mode LastWriteTime Length Name

d---- 20/04/2014 12:12 AM CBS
d---- 19/04/2014 7:48 PM DISM
d---- 19/04/2014 6:56 PM DPX
d---- 14/07/2009 1:32 PM HomeGroup
d---- 20/04/2014 1:11 PM SystemRestore
-a— 19/04/2014 7:52 PM 2831 IE9_NR_Setup.log

Both returns the same results, namely the first level files and folders in the C:\Windows\Logs directory, i.e. all of it’s childitems. So I looked at the help more closely

-Path <String[]> Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.).
    Required?                    false
    Position?                    1
    Default value                Current directory
    Accept pipeline input?       true (ByValue, ByPropertyName)
    Accept wildcard characters?  true</blockquote>

So to me the use of a wildcard in the path string seems to be just a short hand way of filtering results and the explanation attached to ‘example 7’ is either outdated or just plain wrong.

Am I missing something here?

The explanation in the help file might be confusing. It’s example 3 online (

The -Path parameter specifies the child items you want to get. In this case, it’s specifying a folder path, so you want the child items of that folder. Including a wildcard or not doesn’t matter - you’re not getting the item (the directory) either way. So in that regard, the explanation is, at the very least, confusing.

You CAN use a wildcard as a shorthand means of filtering - although that isn’t what this example is doing.

However… this example deals with the filesystem. Get-ChildItem might behave slightly differently in a different provider.

Consider bugging the doc at so Microsoft can clarify it.