A positional parameter accepts a value by its place in a command, so you can omit the parameter name. The value must appear in the correct position. section 3.5.3 section 4.6.3
Use help to identify positional parameters and avoid common mistakes:
- In a syntax summary, square brackets around the parameter name identify a positional parameter, such as [[-Path] <string[]>]. section 3.5.3
- Full help shows the position number; position 0 is the first value after the cmdlet. section 4.6.3
- Put positional values first and in order, then add named parameters such as -Filter. section 4.6.3
- Prefer named parameters in scripts and other commands that will persist; positional syntax is best reserved for quick interactive commands. section 4.6.3 section 19.2
Passing a path positionally
Get-ChildItem /Users is equivalent to Get-ChildItem -Path /Users because -Path occupies position 0. Reordering unnamed values can make a command fail, while named parameters can appear in a different order. section 4.6.3
Parameterized script
A Param() block makes script parameters both named and positional. For example, .\Get-DiskInventory.ps1 SRV-02 supplies the computer name positionally, while -computername SRV02 and -comp SRV02 use the full or abbreviated name. section 19.4
-Path <String[]>
Specifies a path to one or more locations. Wildcards are
permitted. The default location is the current directory (.).
Required? false
Position? 0
Default value Current directory
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? True
Inspect the help entry to see -Path at position 0, its default location, and its accepted input. section 4.6.3




