SwitchParameter Structure
Defines a type of parameter that is evaluated based on its presence on the command line. Cmdlets and functions can define switch parameters that are evaluated by the Windows PowerShell runtime when the parameters of the command are bound.
Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)
System.Management.Automation Namespace
Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)
The following example shows how the declare a parameter of type SwitchParameter .
[Parameter(Position = 1)] public SwitchParameter GoodBye { get { return goodbye; } set { goodbye = value; } } private bool goodbye;
A switch parameter is a parameter that may, or may not, be specified when the command is run. If the parameter is specified, the Windows PowerShell runtime resolves its value as true . If the parameter is not specified, which is typically the default, the parameter value is resolved as false .
Any public static (
Shared
in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Target Platforms
Windows Developer Preview, Windows Server Developer PreviewReference
SwitchParameter MembersSystem.Management.Automation Namespace
Other Resources
Windows PowerShell SDKSend comments about this topic to Microsoft.