
Chapter 1: Getting Started with Windows PowerShell
13
Optional and Required Parameters
Cmdlets may have some parameters that are not required to be used each time the cmdlet is run and are
considered optional. You will find that most cmdlets have at least some optional parameters, especially
cmdlets that modify items, because not all properties of an item require changing at the same time. This
allows you to use only the optional parameters necessary to make the desired changes while leaving out
all other optional parameters.
Then there are other parameters that must always be used when the cmdlet is run. You will find that
most cmdlets that take an action such as creating, modifying, or removing items have at minimum one
required parameter to identify the items on which to take action. If any required parameters are left out
when running a cmdlet, Windows PowerShell prompts the user to enter an input value for each of the
missing required parameters.
The
Identity parameter is one of the most common required parameters, typically used by cmdlets
that need as input the name of the object on which to take some action. For example, the
Set-User
cmdlet modifies attributes on an existing user account in the Active Directory directory service.
The
Identity parameter is required when using Set-User and is used to identify the user account
on which the changes are to be made. ...