Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

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)
'Usage
Dim instance As SwitchParameter

public struct SwitchParameter
public final class SwitchParameter extends ValueType

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 Preview

Send comments about this topic to Microsoft.
Show:
© 2014 Microsoft. All rights reserved.