Chapter 6. Parameters

In some situations, you can issue a Windows PowerShell command simply by using the name of a cmdlet or function. This, typically, results in the default behavior of the cmdlet. (If there is a required parameter, you are prompted to provide it.) The cmdlet behaves as if some implicit parameter has been supplied that specifies how the cmdlet is to execute. For example, if you issue the command

get-command

information about all available commands is displayed in the PowerShell console. The behavior is the same as if you issue either of the following forms of the command:

get-command *

or:

get-command -name *

In the two preceding commands, you supply a parameter value (in this case the wildcard *, which matches all command names) that specifies the commands for which information should be displayed.

In some situations, you need to name the parameter before you can supply a value for it. In such situations, the parameter is termed a named parameter. In other situations, you don't need to provide a name for some parameters. The position of the parameter value in relation to the position of other unnamed parameter values determines how the PowerShell parser interprets the value that you supply. Parameters for which you can, but don't need to, supply a name are termed positional parameters.

Get Professional Windows® PowerShell now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.