Skip to content

Commit 46dd905

Browse files
(AB-568561) [switch] parameter in conceptual docs (#12939)
1 parent 3d1f1d9 commit 46dd905

24 files changed

+97
-92
lines changed

reference/docs-conceptual/developer/cmdlet/background-jobs.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ For more information about how background jobs are handled at the command line,
2323

2424
To write a cmdlet that can be run as a background job, you must complete the following tasks:
2525

26-
- Define an `asJob` switch parameter so that the user can decide whether to run the cmdlet as a background job.
26+
- Define an `AsJob` `[switch]` parameter so that the user can decide whether to run the cmdlet as a
27+
background job.
2728

2829
- Create an object that derives from the [System.Management.Automation.Job](/dotnet/api/System.Management.Automation.Job) class. This object can be a custom job object or a job object provided by Windows PowerShell, such as a [System.Management.Automation.PSEventJob](/dotnet/api/System.Management.Automation.PSEventJob) object.
2930

reference/docs-conceptual/developer/cmdlet/cmdlet-dynamic-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: Cmdlet Dynamic Parameters
99
Cmdlets can define parameters that are available to the user under special conditions, such as when
1010
the argument of another parameter is a specific value. These parameters are added at runtime and are
1111
referred to as dynamic parameters because they're only added when needed. For example, you can
12-
design a cmdlet that adds several parameters only when a specific switch parameter is specified.
12+
design a cmdlet that adds several parameters only when a specific `[switch]` parameter is specified.
1313

1414
> [!NOTE]
1515
> Providers and PowerShell functions can also define dynamic parameters.

reference/docs-conceptual/developer/cmdlet/cmdlet-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ about this attribute, see [Cmdlet Attribute Declaration](cmdlet-attribute-declar
4949
### Cmdlet parameter
5050

5151
The public properties that define the parameters that are available to the user or to the
52-
application that is running the cmdlet. Cmdlets can have required, named, positional, and *switch*
53-
parameters. Switch parameters allow you to define parameters that are evaluated only if the
52+
application that is running the cmdlet. Cmdlets can have required, named, positional, and `[switch]`
53+
parameters. `[switch]` parameters allow you to define parameters that are evaluated only if the
5454
parameters are specified in the call. For more information about the different types of parameters,
5555
see [Cmdlet Parameters](cmdlet-parameters.md).
5656

reference/docs-conceptual/developer/cmdlet/creating-a-cmdlet-to-access-a-data-store.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ public ScriptBlock Script
145145
ScriptBlock script;
146146
```
147147

148-
The `SimpleMatch` parameter is a switch parameter that indicates whether the cmdlet is to explicitly
149-
match the patterns as they are supplied. When the user specifies the parameter at the command line
150-
(`true`), the cmdlet uses the patterns as they are supplied. If the parameter is not specified
151-
(`false`), the cmdlet uses regular expressions. The default for this parameter is `false`.
148+
The `SimpleMatch` parameter is a `[switch]` parameter that indicates whether the cmdlet is to
149+
explicitly match the patterns as they are supplied. When the user specifies the parameter at the
150+
command line (`true`), the cmdlet uses the patterns as they are supplied. If the parameter is not
151+
specified (`false`), the cmdlet uses regular expressions. The default for this parameter is
152+
`false`.
152153

153154
```csharp
154155
[Parameter]
@@ -160,12 +161,12 @@ public SwitchParameter SimpleMatch
160161
private bool simpleMatch;
161162
```
162163

163-
The `CaseSensitive` parameter is a switch parameter that indicates whether a case-sensitive search
164-
is performed. When the user specifies the parameter at the command line (`true`), the cmdlet checks
165-
for the uppercase and lowercase of characters when comparing patterns. If the parameter is not
166-
specified (`false`), the cmdlet does not distinguish between uppercase and lowercase. For example
167-
"MyFile" and "myfile" would both be returned as positive hits. The default for this parameter is
168-
`false`.
164+
The `CaseSensitive` parameter is a `[switch]` parameter that indicates whether a case-sensitive
165+
search is performed. When the user specifies the parameter at the command line (`true`), the cmdlet
166+
checks for the uppercase and lowercase of characters when comparing patterns. If the parameter is
167+
not specified (`false`), the cmdlet does not distinguish between uppercase and lowercase. For
168+
example "MyFile" and "myfile" would both be returned as positive hits. The default for this
169+
parameter is `false`.
169170

170171
```csharp
171172
[Parameter]

reference/docs-conceptual/developer/cmdlet/how-to-declare-cmdlet-parameters.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ title: How to Declare Cmdlet Parameters
55
---
66
# How to Declare Cmdlet Parameters
77

8-
These examples show how to declare named, positional, required, optional, and switch parameters. These examples also show how to define a parameter alias.
8+
These examples show how to declare named, positional, required, optional, and `[switch]`
9+
parameters. These examples also show how to define a parameter alias.
910

1011
## How to Declare a Named Parameter
1112

@@ -69,7 +70,7 @@ For more information about the Parameter attribute, see [Parameter Attribute Dec
6970
private string userName;
7071
```
7172

72-
## How to Declare a Switch Parameter
73+
## How to Declare a `[switch]` parameter
7374

7475
- Define a public property as type [System.Management.Automation.SwitchParameter](/dotnet/api/System.Management.Automation.SwitchParameter), and then declare the Parameter attribute.
7576

reference/docs-conceptual/developer/cmdlet/how-to-declare-dynamic-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: How to Declare Dynamic Parameters
77

88
This example shows how to define dynamic parameters that are added to the cmdlet at runtime. In this
99
example, the `Department` parameter is added to the cmdlet whenever the user specifies the
10-
`Employee` switch parameter. For more information about dynamic parameters, see
10+
`Employee` `[switch]` parameter. For more information about dynamic parameters, see
1111
[Cmdlet Dynamic Parameters][02].
1212

1313
## To define dynamic parameters

reference/docs-conceptual/developer/cmdlet/how-to-support-jobs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ information about background jobs, see [Background Jobs](./background-jobs.md).
1111

1212
## To support jobs
1313

14-
1. Define an `AsJob` switch parameter so that the user can decide whether to run the cmdlet as a
15-
job.
14+
1. Define an `AsJob` `[switch]` parameter so that the user can decide whether to run the cmdlet as
15+
a job.
1616

1717
The following example shows an AsJob parameter declaration.
1818

reference/docs-conceptual/developer/cmdlet/requesting-confirmation-from-cmdlets.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ additional confirmation. For these cases, supplement the
4848
to more finely control the scope of the **Yes to all** response to the confirmation prompt.
4949

5050
If a cmdlet calls the [System.Management.Automation.Cmdlet.ShouldContinue][02] method, the cmdlet
51-
must also provide a `Force` switch parameter. If the user specifies `Force` when the user invokes
52-
the cmdlet, the cmdlet should still call [System.Management.Automation.Cmdlet.ShouldProcess][03],
53-
but it should bypass the call to [System.Management.Automation.Cmdlet.ShouldContinue][02].
51+
must also provide a `Force` `[switch]` parameter. If the user specifies `Force` when the user
52+
invokes the cmdlet, the cmdlet should still call
53+
[System.Management.Automation.Cmdlet.ShouldProcess][03], but it should bypass the call to
54+
[System.Management.Automation.Cmdlet.ShouldContinue][02].
5455

5556
[System.Management.Automation.Cmdlet.ShouldContinue][02] will throw an exception when it's called
5657
from a non-interactive environment where the user can't be prompted. Adding a `Force` parameter

reference/docs-conceptual/developer/cmdlet/strongly-encouraged-development-guidelines.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ cmdlet, do not make the `Process` parameter for another cmdlet a
110110

111111
If your parameter takes only `true` and `false`, define the parameter as type
112112
[System.Management.Automation.SwitchParameter](/dotnet/api/System.Management.Automation.SwitchParameter).
113-
A switch parameter is treated as `true` when it is specified in a command. If the parameter is not
114-
included in a command, Windows PowerShell considers the value of the parameter to be `false`. Do not
115-
define Boolean parameters.
113+
A `[switch]` parameter is treated as `true` when it is specified in a command. If the parameter is
114+
not included in a command, Windows PowerShell considers the value of the parameter to be `false`.
115+
Do not define Boolean parameters.
116116

117117
If your parameter needs to differentiate between 3 values: $true, $false and "unspecified", then
118118
define a parameter of type Nullable\<bool>. The need for a 3rd, "unspecified" value typically occurs

reference/docs-conceptual/developer/cmdlet/types-of-cmdlet-output.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ method. We recommend that you call this method instead of the
2323
[System.Management.Automation.Host.PSHostUserInterface.WriteLine](/dotnet/api/System.Management.Automation.Host.PSHostUserInterface.WriteLine)
2424
methods.
2525

26-
You can provide a **PassThru** switch parameter for cmdlets that do not typically return objects.
27-
When the **PassThru** switch parameter is specified at the command line, the cmdlet is asked to
28-
return an object. For an example of a cmdlet that has a **PassThru** parameter, see
26+
You can provide a **PassThru** `[switch]` parameter for cmdlets that do not typically return
27+
objects. When the **PassThru** `[switch]` parameter is specified at the command line, the cmdlet is
28+
asked to return an object. For an example of a cmdlet that has a **PassThru** parameter, see
2929
[Add-History](/powershell/module/Microsoft.PowerShell.Core/Add-History).
3030

3131
### Error output

0 commit comments

Comments
 (0)