Defining parameter sets
A parameter set in PowerShell groups different parameters together. In some cases, this is used to change the output of a command; in others, it provides a different way of supplying a piece of information.
For example, the output from the Get-Process
command changes if the Module
parameter or, to a lesser extent, the IncludeUserName
parameter is supplied.
The Get-ChildItem
command also has two parameter sets: one that accepts a Path
with wildcard support and another that accepts a LiteralPath
that does not support wildcards.
Parameter sets are declared using the ParameterSetName
property of the Parameter
attribute.
The following example has two parameter sets; each parameter set contains a single parameter:
function Get-InputObject {
[CmdletBinding()]
param (
[Parameter(ParameterSetName = 'FirstSetName')]
$Parameter1,
[Parameter(ParameterSetName = 'SecondSetName')]
$Parameter2...