Skip to content

Commit 9fc54e7

Browse files
(AB-568561) Use "[switch] parameter" in reference content (#12937)
* (AB-568561) `[switch]` parameter in CimCmdlets * (AB-568561) `[switch]` parameter in Management * (AB-568561) `[switch]` parameter in Utility * (AB-568561) `[switch]` parameter in Core cmdlets * (AB-568561) `[switch]` parameter in about topics * (MAINT) Address copilot feedback
1 parent d894c5c commit 9fc54e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+182
-186
lines changed

reference/5.1/CimCmdlets/New-CimSession.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ By default, the `New-CimSession` cmdlet establishes a connection with a remote W
331331
endpoint for two reasons: to verify that the remote server is listening on the port number that is
332332
specified using the **Port** parameter, and to verify the specified account credentials. The
333333
verification is accomplished using a standard WS-Identity operation. You can add the
334-
**SkipTestConnection** switch parameter if the remote WS-Management endpoint cannot use WS-Identify,
335-
or to reduce some data transmission time.
334+
**SkipTestConnection** `[switch]` parameter if the remote WS-Management endpoint cannot use
335+
WS-Identify, or to reduce some data transmission time.
336336

337337
```yaml
338338
Type: System.Management.Automation.SwitchParameter

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

Lines changed: 5 additions & 6 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
206-
parameter. When you use the **ListImported** parameter, the cmdlet return
205+
For example, the **ListImported** parameter of `Get-Command` is a `[switch]`
206+
parameter. When you use the **ListImported** parameter, the cmdlet returns
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/5.1/Microsoft.PowerShell.Core/Disable-PSRemoting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ A loopback connection is created when the following conditions are met:
212212
- The computer name to connect to is 'localhost'.
213213
- No credentials are passed in. Current logged in user (implicit credentials) is used for the
214214
connection.
215-
- The **EnableNetworkAccess** switch parameter is used.
215+
- The **EnableNetworkAccess** `[switch]` parameter is used.
216216

217217
For more information on loopback connections, see [New-PSSession](New-PSSession.md) document.
218218

reference/5.1/Microsoft.PowerShell.Core/Get-Help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Get-Help Format-Table -Parameter GroupBy
191191
```
192192

193193
The **Examples** parameter displays the help file's **NAME** and **SYNOPSIS** sections, and all the
194-
Examples. You can't specify an Example number because the **Examples** parameter is a switch
194+
Examples. You can't specify an Example number because the **Examples** parameter is a `[switch]`
195195
parameter.
196196

197197
The **Parameter** parameter displays only the descriptions of the specified parameters. If you

reference/5.1/Microsoft.PowerShell.Core/Where-Object.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ command.
256256
All PowerShell comparison operators are valid in the scriptblock format. For more information,
257257
see [about_Comparison_Operators](./About/about_Comparison_Operators.md).
258258

259-
- **Simplified syntax**. To enable the simiplified syntax, `Where-Object` includes 31 switch
259+
- **Simplified syntax**. To enable the simplified syntax, `Where-Object` includes 31 `[switch]`
260260
parameters that represent the comparison operators. The simplified syntax is easier to read and
261-
write than the scriptblock syntax. You can combine one of the switch parameters with the
261+
write than the scriptblock syntax. You can combine one of the `[switch]` parameters with the
262262
**Property** and **Value** parameters to create a command that filters objects based on the
263263
values of their properties.
264264

@@ -271,7 +271,7 @@ command.
271271

272272
As shown in the example, the parameter names **Property** and **Value** are optional. The
273273
**Property** parameter is a positional parameter mapped to position `0`. The **Value** parameter
274-
is a positional parameter mapped to position `1`. The switch parameter, used to specify the
274+
is a positional parameter mapped to position `1`. The `[switch]` parameter, used to specify the
275275
comparison, can be used in any position.
276276

277277
The simplified syntax was introduced in Windows PowerShell 3.0. For more information, see

reference/5.1/Microsoft.PowerShell.Utility/Show-Command.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ all installed modules. To find the commands in a module, select the module from
3535
drop-down list. To select a command, click the command name.
3636

3737
To use the command window, select a command, either by using the Name or by clicking the command
38-
name in the **Commands** list. Each parameter set is displayed on a separate tab. Asterisks indicate
39-
the mandatory parameters. To enter values for a parameter, type the value in the text box or select
40-
the value from the drop-down box. To add a switch parameter, click to select the parameter check
41-
box.
38+
name in the **Commands** list. Each parameter set is displayed on a separate tab. Asterisks
39+
indicate the mandatory parameters. To enter values for a parameter, type the value in the text box
40+
or select the value from the drop-down box. To add a `[switch]` parameter, click to select the
41+
parameter check box.
4242

4343
When you're ready, you can click **Copy** to copy the command that you've created to the clipboard
4444
or click **Run** to run the command. You can also use the **PassThru** parameter to return the

0 commit comments

Comments
 (0)