Skip to main content

Posts

Showing posts from April, 2016

Positional Parameters and Switch Parameters Odd Behavior

So here is a neat one from my class today.  I love it when someone comes in and looks at a problem from a different perspective.  Take a look at these two lines of code: Get-ChildItem C:\Windows -Recurse Get-ChildItem -Recurse C:\Windows They both work!  This is what caught my attention. Look at the same command with all of the parameters named. Get-ChildItem -Path C:\Windows -Recurse In the first example, we are using the –Path parameter as positional.  Here is the information form the help file: PS C:\> Get-Help Get-ChildItem -Parameter Path -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 You can see it i