Skip to content

Commit 87f0795

Browse files
Merge pull request #12940 from MicrosoftDocs/main
Auto Publish – main to live - 2026-04-08 22:00 UTC
2 parents 5d98c63 + 46dd905 commit 87f0795

82 files changed

Lines changed: 471 additions & 532 deletions

File tree

Some content is hidden

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

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_Functions_Advanced_Parameters.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains how to add parameters to advanced functions.
33
Locale: en-US
4-
ms.date: 03/10/2026
4+
ms.date: 04/08/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Functions_Advanced_Parameters
@@ -178,68 +178,68 @@ param(
178178
)
179179
```
180180

181-
## Switch parameters
181+
## `[switch]` parameters
182182

183-
Switch parameters are parameters that take no parameter value. Instead, they
184-
convey a Boolean true-or-false value through their presence or absence, so that
185-
when a switch parameter is present it has a **true** value and when absent it
186-
has a **false** value.
183+
`[switch]` parameters are parameters that take no parameter value. Instead,
184+
they convey a Boolean true-or-false value through their presence or absence, so
185+
that when a `[switch]` parameter is present it has a **true** value and when
186+
absent it has a **false** value.
187187

188-
For example, the **Recurse** parameter of `Get-ChildItem` is a switch
188+
For example, the **Recurse** parameter of `Get-ChildItem` is a `[switch]`
189189
parameter.
190190

191-
To create a switch parameter in a function, specify the `[switch]` type in the
192-
parameter definition. The following example shows the definition of a switch
193-
parameter that could be used to provide an option to output data as a byte
194-
array:
191+
The following example shows the definition of a `[switch]` parameter that could
192+
be used to provide an option to output data as a byte array:
195193

196194
```powershell
197195
param([switch]$AsByteArray)
198196
```
199197

200-
Switch parameters are easy to use and are preferred over Boolean parameters
198+
`[switch]` parameters are easy to use and are preferred over Boolean parameters
201199
that have a less natural syntax for PowerShell.
202200

203-
To use a switch parameter, include the parameter in the command. For example:
201+
To use a `[switch]` parameter, include the parameter in the command. For
202+
example:
204203

205204
`-IncludeAll`
206205

207206
To use a Boolean parameter, you must provide the parameter and a Boolean value.
208207

209208
`-IncludeAll $true`
210209

211-
When creating switch parameters, choose the parameter name carefully. Be sure
212-
that the parameter name communicates the effect of the parameter to the user.
213-
Avoid ambiguous terms, such as **Filter** or **Maximum** that might imply a
214-
value is required.
210+
When creating `[switch]` parameters, choose the parameter name carefully. Be
211+
sure that the parameter name communicates the effect of the parameter to the
212+
user. Avoid ambiguous terms, such as **Filter** or **Maximum** that might imply
213+
a value is required.
215214

216-
### Switch parameter design considerations
215+
### `[switch]` parameter design considerations
217216

218-
- Don't set a default value for a switch parameter. Switch parameter always
219-
default to false.
220-
- Don't make switch parameters positional. By default, switch parameters are
221-
excluded from positional parameters. You _can_ override that in the
222-
**Parameter** attribute, but it can confuse users.
223-
- Design switch parameters so that using parameter changes the default behavior
217+
- Don't set a default value for a `[switch]` parameter. `[switch]` parameters
218+
always default to false.
219+
- Don't make `[switch]` parameters positional. By default, `[switch]`
220+
parameters are excluded from positional parameters. You _can_ override that
221+
in the **Parameter** attribute, but it can confuse users.
222+
- Design `[switch]` parameters so that using them changes the default behavior
224223
of the command to a less common or more complicated mode. The simplest
225224
behavior of a command should be the default behavior that doesn't require the
226-
use of switch parameters.
227-
- Don't make switch parameters mandatory. The only case where it's helpful to
228-
make a switch parameter mandatory is when it's needed to differentiate a
229-
parameter set.
230-
- Use the switch parameter variable directly in a conditional expression. The
231-
`SwitchParameter` type implicitly converts to Boolean. For example:
225+
use of `[switch]` parameters.
226+
- Don't make `[switch]` parameters mandatory. The only case where it's helpful
227+
to make a `[switch]` parameter mandatory is when it's needed to differentiate
228+
a parameter set.
229+
- Use the `[switch]` parameter variable directly in a conditional expression.
230+
The `SwitchParameter` type implicitly converts to Boolean. For example:
232231

233232
```powershell
234233
if ($MySwitch) { ... }
235234
```
236235

237-
- Always base the behavior controlled by the switch on the value of the switch,
238-
not the presence of the parameter. There are several ways to test for the
239-
presence of a switch parameters:
236+
- Always base the behavior controlled by the `[switch]` parameter on the
237+
_value_ of the parameter, not its _presence_. There are several ways to test
238+
for the presence of a `[switch]` parameters:
240239

241-
- `$PSBoundParameters` contains the switch parameter name as a key
242-
- `$MyInvocation.BoundParameters` contains the switch parameter name as a key
240+
- `$PSBoundParameters` contains the `[switch]` parameter name as a key
241+
- `$MyInvocation.BoundParameters` contains the `[switch]` parameter name as a
242+
key
243243
- `$PSCmdlet.ParameterSetName` when the switch defines a unique parameter set
244244

245245
For example, it's possible to provide an explicit value for the switch using
@@ -773,7 +773,7 @@ Use the **System.Obsolete** attribute to mark parameters that are no longer
773773
supported. This can be useful when you want to remove a parameter from a
774774
function but you don't want to break existing scripts that use the function.
775775

776-
For example, consider a function that has a **NoTypeInformation** switch
776+
For example, consider a function that has a **NoTypeInformation** `[switch]`
777777
parameter that controls whether type information is included in the output. You
778778
want to make that behavior the default and remove the parameter from the
779779
function. However, you don't want to break existing scripts that use the
@@ -783,7 +783,7 @@ explains the change.
783783
```powershell
784784
param(
785785
[System.Obsolete("The NoTypeInformation parameter is obsolete.")]
786-
[SwitchParameter]$NoTypeInformation
786+
[switch]$NoTypeInformation
787787
)
788788
```
789789

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

0 commit comments

Comments
 (0)