Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Help with the basics.

$
0
0

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*

Description

———–

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

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?


Viewing all articles
Browse latest Browse all 13067

Trending Articles