Skip to content

Commit 0dfbd2e

Browse files
(AB-568561) [switch] parameter in about topics
1 parent e9f8dde commit 0dfbd2e

26 files changed

+120
-125
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_Command_Syntax.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,18 @@ The syntax diagrams use the following symbols:
198198
- Parameters with no values
199199

200200
Some parameters don't accept input, so they don't have a parameter value.
201-
Parameters without values are _switch parameters_. Switch parameters are used
202-
like boolean values. They default to `$false`. When you use a switch
203-
parameter, the value is set to `$true`.
201+
Parameters without values are _`[switch]` parameters_. `[switch]` parameters
202+
are used like boolean values. They default to `$false`. When you use a
203+
`[switch]` parameter, the value is set to `$true`.
204204

205-
For example, the **ListImported** parameter of `Get-Command` is a switch
205+
For example, the **ListImported** parameter of `Get-Command` is a `[switch]`
206206
parameter. When you use the **ListImported** parameter, the cmdlet return
207207
only commands that were imported from modules in the current session.
208208

209209
```Syntax
210210
Get-Command [-ListImported]
211211
```
212212

213-
<!-- So what are these `[ ]`? - square brackets, duh! -->
214213
- Brackets `[ ]` around parameters indicate optional items. A parameter and
215214
its value can be optional. For example, the **CommandType** parameter of
216215
`Get-Command` and its value are enclosed in brackets because they're both

reference/5.1/Microsoft.PowerShell.Core/About/about_Functions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ For more information about the standard PowerShell verbs, see
239239
## Functions with parameters
240240

241241
You can use parameters with functions, including named parameters, positional
242-
parameters, switch parameters, and dynamic parameters. For more information
242+
parameters, `[switch]` parameters, and dynamic parameters. For more information
243243
about dynamic parameters in functions, see
244244
[about_Functions_Advanced_Parameters][09].
245245

@@ -379,13 +379,12 @@ Get-Extension myTextFile
379379
myTextFile.txt
380380
```
381381

382-
### Switch parameters
382+
### `[switch]` parameters
383383

384384
A switch is a parameter that doesn't require a value. Instead, you type the
385-
function name followed by the name of the switch parameter.
385+
function name followed by the name of the `[switch]` parameter.
386386

387-
To define a switch parameter, specify the type `[switch]` before the parameter
388-
name, as shown in the following example:
387+
The following example shows how you define a `[switch]` parameter:
389388

390389
```powershell
391390
function Switch-Item {
@@ -395,8 +394,9 @@ function Switch-Item {
395394
}
396395
```
397396

398-
When you type the `On` switch parameter after the function name, the function
399-
displays `Switch on`. Without the switch parameter, it displays `Switch off`.
397+
When you type the `On` `[switch]` parameter after the function name, the
398+
function displays `Switch on`. Without the `[switch]` parameter, it displays
399+
`Switch off`.
400400

401401
```powershell
402402
Switch-Item -On

reference/5.1/Microsoft.PowerShell.Core/About/about_Parameters_Default_Values.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ $PSDefaultParameterValues = @{
104104
```
105105

106106
The cmdlet and parameter names can contain wildcard characters. Use `$true` and
107-
`$false` to set values for switch parameters, such as **Verbose**. This example
108-
sets the common parameter **Verbose** to `$true` for all commands.
107+
`$false` to set values for `[switch]` parameters, such as **Verbose**. This
108+
example sets the common parameter **Verbose** to `$true` for all commands.
109109

110110
```powershell
111111
$PSDefaultParameterValues = @{'*:Verbose'=$true}
@@ -162,9 +162,9 @@ You can use a scriptblock to specify different default values for a parameter
162162
under different conditions. PowerShell evaluates the scriptblock and uses the
163163
result as the default parameter value.
164164

165-
The `Format-Table:AutoSize` key sets that switch parameter to a default value
166-
of `$true` The `if` statement contains a condition that the `$Host.Name` must
167-
be `ConsoleHost`.
165+
The `Format-Table:AutoSize` key sets that `[switch]` parameter to a default
166+
value of `$true` The `if` statement contains a condition that the `$Host.Name`
167+
must be `ConsoleHost`.
168168

169169
```powershell
170170
$PSDefaultParameterValues = @{

reference/5.1/Microsoft.PowerShell.Core/About/about_Requires.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ For example:
211211
212212
#### -RunAsAdministrator
213213

214-
When this switch parameter is added to your `#Requires` statement, it specifies
215-
that the PowerShell session in which you're running the script must be started
216-
with elevated user rights. The **RunAsAdministrator** parameter is ignored on a
217-
non-Windows operating system. The **RunAsAdministrator** parameter was
218-
introduced in PowerShell 4.0.
214+
When this `[switch]` parameter is added to your `#Requires` statement, it
215+
specifies that the PowerShell session in which you're running the script must
216+
be started with elevated user rights. The **RunAsAdministrator** parameter is
217+
ignored on a non-Windows operating system. The **RunAsAdministrator** parameter
218+
was introduced in PowerShell 4.0.
219219

220220
For example:
221221

reference/5.1/Microsoft.PowerShell.Core/About/about_Splatting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ command so you don't pass more than one value for each parameter.
4949
## Splatting with hash tables
5050

5151
Use a hash table to splat parameter name and value pairs. You can use this
52-
format for all parameter types, including positional and switch parameters.
52+
format for all parameter types, including positional and `[switch]` parameters.
5353
Positional parameters must be assigned by name.
5454

5555
The following examples compare two `Copy-Item` commands that copy the Test.txt
@@ -68,7 +68,7 @@ table of parameter-name and parameter-value pairs and stores it in the
6868
variable in a command with splatting. The At symbol (`@HashArguments`) replaces
6969
the dollar sign (`$HashArguments`) in the command.
7070

71-
To provide a value for the **WhatIf** switch parameter, use `$true` or
71+
To provide a value for the **WhatIf** `[switch]` parameter, use `$true` or
7272
`$false`.
7373

7474
```powershell

reference/7.4/Microsoft.PowerShell.Core/About/about_Command_Syntax.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,18 @@ The syntax diagrams use the following symbols:
198198
- Parameters with no values
199199

200200
Some parameters don't accept input, so they don't have a parameter value.
201-
Parameters without values are _switch parameters_. Switch parameters are used
202-
like boolean values. They default to `$false`. When you use a switch
203-
parameter, the value is set to `$true`.
201+
Parameters without values are _`[switch]` parameters_. `[switch]` parameters
202+
are used like boolean values. They default to `$false`. When you use a
203+
`[switch]` parameter, the value is set to `$true`.
204204

205-
For example, the **ListImported** parameter of `Get-Command` is a switch
205+
For example, the **ListImported** parameter of `Get-Command` is a `[switch]`
206206
parameter. When you use the **ListImported** parameter, the cmdlet return
207207
only commands that were imported from modules in the current session.
208208

209209
```Syntax
210210
Get-Command [-ListImported]
211211
```
212212

213-
<!-- So what are these `[ ]`? - square brackets, duh! -->
214213
- Brackets `[ ]` around parameters indicate optional items. A parameter and
215214
its value can be optional. For example, the **CommandType** parameter of
216215
`Get-Command` and its value are enclosed in brackets because they're both

reference/7.4/Microsoft.PowerShell.Core/About/about_Functions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ For more information about the standard PowerShell verbs, see
263263
## Functions with parameters
264264

265265
You can use parameters with functions, including named parameters, positional
266-
parameters, switch parameters, and dynamic parameters. For more information
266+
parameters, `[switch]` parameters, and dynamic parameters. For more information
267267
about dynamic parameters in functions, see
268268
[about_Functions_Advanced_Parameters][09].
269269

@@ -403,13 +403,12 @@ Get-Extension myTextFile
403403
myTextFile.txt
404404
```
405405

406-
### Switch parameters
406+
### `[switch]` parameters
407407

408408
A switch is a parameter that doesn't require a value. Instead, you type the
409-
function name followed by the name of the switch parameter.
409+
function name followed by the name of the `[switch]` parameter.
410410

411-
To define a switch parameter, specify the type `[switch]` before the parameter
412-
name, as shown in the following example:
411+
The following example shows how you define a `[switch]` parameter:
413412

414413
```powershell
415414
function Switch-Item {
@@ -419,8 +418,9 @@ function Switch-Item {
419418
}
420419
```
421420

422-
When you type the `On` switch parameter after the function name, the function
423-
displays `Switch on`. Without the switch parameter, it displays `Switch off`.
421+
When you type the `On` `[switch]` parameter after the function name, the
422+
function displays `Switch on`. Without the `[switch]` parameter, it displays
423+
`Switch off`.
424424

425425
```powershell
426426
Switch-Item -On

reference/7.4/Microsoft.PowerShell.Core/About/about_Parameters_Default_Values.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ $PSDefaultParameterValues = @{
104104
```
105105

106106
The cmdlet and parameter names can contain wildcard characters. Use `$true` and
107-
`$false` to set values for switch parameters, such as **Verbose**. This example
108-
sets the common parameter **Verbose** to `$true` for all commands.
107+
`$false` to set values for `[switch]` parameters, such as **Verbose**. This
108+
example sets the common parameter **Verbose** to `$true` for all commands.
109109

110110
```powershell
111111
$PSDefaultParameterValues = @{'*:Verbose'=$true}
@@ -162,9 +162,9 @@ You can use a scriptblock to specify different default values for a parameter
162162
under different conditions. PowerShell evaluates the scriptblock and uses the
163163
result as the default parameter value.
164164

165-
The `Format-Table:AutoSize` key sets that switch parameter to a default value
166-
of `$true` The `if` statement contains a condition that the `$Host.Name` must
167-
be `ConsoleHost`.
165+
The `Format-Table:AutoSize` key sets that `[switch]` parameter to a default
166+
value of `$true` The `if` statement contains a condition that the `$Host.Name`
167+
must be `ConsoleHost`.
168168

169169
```powershell
170170
$PSDefaultParameterValues = @{

reference/7.4/Microsoft.PowerShell.Core/About/about_PowerShell_Editions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ Get-Module -ListAvailable BitsTransfer
198198
# No output
199199
```
200200

201-
In both cases, the `-SkipEditionCheck` switch parameter can be used to override
202-
this behavior:
201+
In both cases, the `-SkipEditionCheck` `[switch]` parameter can be used to
202+
override this behavior:
203203

204204
```powershell
205205
Get-Module -ListAvailable -SkipEditionCheck BitsTransfer

reference/7.4/Microsoft.PowerShell.Core/About/about_Pwsh.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ and any parameters. File must be the last parameter in the command, because all
6969
characters typed after the File parameter name are interpreted as the script
7070
filepath followed by the script parameters.
7171

72-
Typically, the switch parameters of a script are either included or omitted.
73-
For example, the following command uses the **All** parameter of the
72+
Typically, the `[switch]` parameters of a script are either included or
73+
omitted. For example, the following command uses the **All** parameter of the
7474
`Get-Script.ps1` script file: `-File .\Get-Script.ps1 -All`
7575

76-
In rare cases, you might need to provide a **Boolean** value for a switch
77-
parameter. To provide a **Boolean** value for a switch parameter in the value
78-
of the **File** parameter, Use the parameter normally followed immediately by a
79-
colon and the boolean value, such as the following:
80-
`-File .\Get-Script.ps1 -All:$false`.
76+
In rare cases, you might need to provide a **Boolean** value for a `[switch]`
77+
parameter. To provide a **Boolean** value for a `[switch]` parameter in the
78+
value of the **File** parameter, Use the parameter normally followed
79+
immediately by a colon and the boolean value, such as the following: `-File
80+
.\Get-Script.ps1 -All:$false`.
8181

8282
Parameters passed to the script are passed as literal strings, after
8383
interpretation by the current shell. For example, if you are in `cmd.exe` and

0 commit comments

Comments
 (0)