Skip to content

Commit 0718714

Browse files
committed
Standardize terminology around "simplified syntax"
1 parent f3a9fee commit 0718714

File tree

8 files changed

+156
-88
lines changed

8 files changed

+156
-88
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 04/26/2024
5+
ms.date: 04/23/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: ForEach-Object
@@ -36,14 +36,17 @@ input objects can be piped to the cmdlet or specified using the **InputObject**
3636
Starting in Windows PowerShell 3.0, there are two different ways to construct a `ForEach-Object`
3737
command.
3838

39-
- **Script block**. You can use a script block to specify the operation. Within the script block,
39+
- **Script block syntax**. You can use a script block to specify the operation. Within the script block,
4040
use the `$_` variable to represent the current object. The script block is the value of the
4141
**Process** parameter. The script block can contain any PowerShell script.
4242

4343
For example, the following command gets the value of the **ProcessName** property of each process
4444
on the computer.
4545

46-
`Get-Process | ForEach-Object {$_.ProcessName}`
46+
47+
```powershell
48+
Get-Process | ForEach-Object {$_.ProcessName}
49+
```
4750

4851
`ForEach-Object` supports the `begin`, `process`, and `end` blocks as described in
4952
[about_Functions](about/about_functions.md#piping-objects-to-functions).
@@ -52,14 +55,19 @@ command.
5255
> The script blocks run in the caller's scope. Therefore, the blocks have access to variables in
5356
> that scope and can create new variables that persist in that scope after the cmdlet completes.
5457
55-
- **Operation statement**. You can also write an operation statement, which is much more like
56-
natural language. You can use the operation statement to specify a property value or call a
57-
method. Operation statements were introduced in Windows PowerShell 3.0.
58+
- **Simplified syntax**. Using the simplified syntax, you a property or method name of the object in
59+
the pipeline. `ForEach-Object` returns the value of the property or method for each object in the
60+
the pipeline.
5861

5962
For example, the following command also gets the value of the **ProcessName** property of each
6063
process on the computer.
6164

62-
`Get-Process | ForEach-Object ProcessName`
65+
```powershell
66+
Get-Process | ForEach-Object ProcessName
67+
```
68+
69+
The simplified syntax was introduced in Windows PowerShell 3.0. For more information, see
70+
[about_Simplified_Syntax](About/about_Simplified_Syntax.md).
6371

6472
## EXAMPLES
6573

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 04/26/2024
5+
ms.date: 04/23/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/where-object?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Where-Object
@@ -241,32 +241,41 @@ particular version of Windows.
241241
Starting in Windows PowerShell 3.0, there are two different ways to construct a `Where-Object`
242242
command.
243243

244-
- **Script block**. You can use a script block to specify the property name, a comparison operator,
244+
- **Script block syntax**. You can use a script block to specify the property name, a comparison operator,
245245
and a property value. `Where-Object` returns all objects for which the script block statement is
246246
true.
247247

248-
For example, the following command gets processes in the `Normal` priority class, that is,
249-
processes where the value of the **PriorityClass** property equals `Normal`.
248+
For example, the following command gets processes where the value of the **PriorityClass**
249+
property equals `Normal`.
250250

251-
`Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}`
251+
```powershell
252+
Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}
253+
```
252254

253255
All PowerShell comparison operators are valid in the script block format. For more information,
254256
see [about_Comparison_Operators](./About/about_Comparison_Operators.md).
255257

256-
- **Comparison statement**. You can also write a comparison statement, which is much more like
257-
natural language. Comparison statements were introduced in Windows PowerShell 3.0.
258+
- **Simplified syntax**. To enable the simiplified syntax, `Where-Object` includes 31 swicth
259+
parameters that represent the comparison operators. The simplified syntax is easier to read and
260+
write than the script block syntax. You can combine one of the switch parameters with the
261+
**Property** and **Value** parameters to create a command that filters objects based on the values of
262+
their properties.
258263

259264
For example, the following commands also get processes that have a priority class of `Normal`.
260265
These commands are equivalent and you can use them interchangeably.
261266

262-
`Get-Process | Where-Object -Property PriorityClass -EQ -Value "Normal"`
267+
```powershell
268+
Get-Process | Where-Object -Property PriorityClass -Value Normal -EQ
269+
Get-Process | Where-Object PriorityClass -EQ Normal
270+
```
263271

264-
`Get-Process | Where-Object PriorityClass -EQ "Normal"`
272+
As shown in the example, the parameter names **Property** and **Value** are optional. The
273+
**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
275+
comparison, can be used in any position.
265276

266-
Starting in Windows PowerShell 3.0, `Where-Object` adds comparison operators as parameters in a
267-
`Where-Object` command. Unless specified, all operators are case-insensitive. Before Windows
268-
PowerShell 3.0, the comparison operators in the PowerShell language were only usable in script
269-
blocks.
277+
The simplfied syntax was introduced in Windows PowerShell 3.0. For more information, see
278+
[about_Simplified_Syntax](About/about_Simplified_Syntax.md).
270279

271280
When you provide a single **Property** to `Where-Object`, the cmdlet treats the value of the
272281
property as a boolean expression. When the value of the property's **Length** isn't zero, the

reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 04/13/2025
5+
ms.date: 04/23/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: ForEach-Object
@@ -45,14 +45,17 @@ input objects can be piped to the cmdlet or specified using the **InputObject**
4545
Starting in Windows PowerShell 3.0, there are two different ways to construct a `ForEach-Object`
4646
command.
4747

48-
- **Script block**. You can use a script block to specify the operation. Within the script block,
48+
- **Script block syntax**. You can use a script block to specify the operation. Within the script block,
4949
use the `$_` variable to represent the current object. The script block is the value of the
5050
**Process** parameter. The script block can contain any PowerShell script.
5151

5252
For example, the following command gets the value of the **ProcessName** property of each process
5353
on the computer.
5454

55-
`Get-Process | ForEach-Object {$_.ProcessName}`
55+
56+
```powershell
57+
Get-Process | ForEach-Object {$_.ProcessName}
58+
```
5659

5760
`ForEach-Object` supports the `begin`, `process`, and `end` blocks as described in
5861
[about_Functions](about/about_functions.md#piping-objects-to-functions).
@@ -61,14 +64,19 @@ command.
6164
> The script blocks run in the caller's scope. Therefore, the blocks have access to variables in
6265
> that scope and can create new variables that persist in that scope after the cmdlet completes.
6366
64-
- **Operation statement**. You can also write an operation statement, which is much more like
65-
natural language. You can use the operation statement to specify a property value or call a
66-
method. Operation statements were introduced in Windows PowerShell 3.0.
67+
- **Simplified syntax**. Using the simplified syntax, you a property or method name of the object in
68+
the pipeline. `ForEach-Object` returns the value of the property or method for each object in the
69+
the pipeline.
6770

6871
For example, the following command also gets the value of the **ProcessName** property of each
6972
process on the computer.
7073

71-
`Get-Process | ForEach-Object ProcessName`
74+
```powershell
75+
Get-Process | ForEach-Object ProcessName
76+
```
77+
78+
The simplified syntax was introduced in Windows PowerShell 3.0. For more information, see
79+
[about_Simplified_Syntax](About/about_Simplified_Syntax.md).
7280

7381
- **Parallel running script block**. Beginning with PowerShell 7.0, a third parameter set is
7482
available that runs each script block in parallel. The **ThrottleLimit** parameter limits the

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

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 04/26/2024
5+
ms.date: 04/23/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/where-object?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Where-Object
@@ -248,32 +248,41 @@ particular version of Windows.
248248
Starting in Windows PowerShell 3.0, there are two different ways to construct a `Where-Object`
249249
command.
250250

251-
- **Script block**. You can use a script block to specify the property name, a comparison operator,
251+
- **Script block syntax**. You can use a script block to specify the property name, a comparison operator,
252252
and a property value. `Where-Object` returns all objects for which the script block statement is
253253
true.
254254

255-
For example, the following command gets processes in the `Normal` priority class, that is,
256-
processes where the value of the **PriorityClass** property equals `Normal`.
255+
For example, the following command gets processes where the value of the **PriorityClass**
256+
property equals `Normal`.
257257

258-
`Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}`
258+
```powershell
259+
Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}
260+
```
259261

260262
All PowerShell comparison operators are valid in the script block format. For more information,
261263
see [about_Comparison_Operators](./About/about_Comparison_Operators.md).
262264

263-
- **Comparison statement**. You can also write a comparison statement, which is much more like
264-
natural language. Comparison statements were introduced in Windows PowerShell 3.0.
265+
- **Simplified syntax**. To enable the simiplified syntax, `Where-Object` includes 31 swicth
266+
parameters that represent the comparison operators. The simplified syntax is easier to read and
267+
write than the script block syntax. You can combine one of the switch parameters with the
268+
**Property** and **Value** parameters to create a command that filters objects based on the values of
269+
their properties.
265270

266271
For example, the following commands also get processes that have a priority class of `Normal`.
267272
These commands are equivalent and you can use them interchangeably.
268273

269-
`Get-Process | Where-Object -Property PriorityClass -EQ -Value "Normal"`
274+
```powershell
275+
Get-Process | Where-Object -Property PriorityClass -Value Normal -EQ
276+
Get-Process | Where-Object PriorityClass -EQ Normal
277+
```
270278

271-
`Get-Process | Where-Object PriorityClass -EQ "Normal"`
279+
As shown in the example, the parameter names **Property** and **Value** are optional. The
280+
**Property** parameter is a positional parameter mapped to position `0`. The **Value** parameter
281+
is a positional parameter mapped to position `1`. The switch parameter, used to specify the
282+
comparison, can be used in any position.
272283

273-
Starting in Windows PowerShell 3.0, `Where-Object` adds comparison operators as parameters in a
274-
`Where-Object` command. Unless specified, all operators are case-insensitive. Before Windows
275-
PowerShell 3.0, the comparison operators in the PowerShell language were only usable in script
276-
blocks.
284+
The simplfied syntax was introduced in Windows PowerShell 3.0. For more information, see
285+
[about_Simplified_Syntax](About/about_Simplified_Syntax.md).
277286

278287
When you provide a single **Property** to `Where-Object`, the cmdlet treats the value of the
279288
property as a boolean expression. When the value of the property's **Length** isn't zero, the
@@ -1208,4 +1217,4 @@ You can read more about these methods here [about_Arrays](./About/about_Arrays.m
12081217

12091218
[Tee-Object](../Microsoft.PowerShell.Utility/Tee-Object.md)
12101219

1211-
[about_Booleans](about/about_Booleans.md)
1220+
[about_Booleans](./About/about_Booleans.md)

reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 04/13/2025
5+
ms.date: 04/23/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.5&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: ForEach-Object
@@ -45,14 +45,17 @@ input objects can be piped to the cmdlet or specified using the **InputObject**
4545
Starting in Windows PowerShell 3.0, there are two different ways to construct a `ForEach-Object`
4646
command.
4747

48-
- **Script block**. You can use a script block to specify the operation. Within the script block,
48+
- **Script block syntax**. You can use a script block to specify the operation. Within the script block,
4949
use the `$_` variable to represent the current object. The script block is the value of the
5050
**Process** parameter. The script block can contain any PowerShell script.
5151

5252
For example, the following command gets the value of the **ProcessName** property of each process
5353
on the computer.
5454

55-
`Get-Process | ForEach-Object {$_.ProcessName}`
55+
56+
```powershell
57+
Get-Process | ForEach-Object {$_.ProcessName}
58+
```
5659

5760
`ForEach-Object` supports the `begin`, `process`, and `end` blocks as described in
5861
[about_Functions](about/about_functions.md#piping-objects-to-functions).
@@ -61,14 +64,19 @@ command.
6164
> The script blocks run in the caller's scope. Therefore, the blocks have access to variables in
6265
> that scope and can create new variables that persist in that scope after the cmdlet completes.
6366
64-
- **Operation statement**. You can also write an operation statement, which is much more like
65-
natural language. You can use the operation statement to specify a property value or call a
66-
method. Operation statements were introduced in Windows PowerShell 3.0.
67+
- **Simplified syntax**. Using the simplified syntax, you a property or method name of the object in
68+
the pipeline. `ForEach-Object` returns the value of the property or method for each object in the
69+
the pipeline.
6770

6871
For example, the following command also gets the value of the **ProcessName** property of each
6972
process on the computer.
7073

71-
`Get-Process | ForEach-Object ProcessName`
74+
```powershell
75+
Get-Process | ForEach-Object ProcessName
76+
```
77+
78+
The simplified syntax was introduced in Windows PowerShell 3.0. For more information, see
79+
[about_Simplified_Syntax](About/about_Simplified_Syntax.md).
7280

7381
- **Parallel running script block**. Beginning with PowerShell 7.0, a third parameter set is
7482
available that runs each script block in parallel. The **ThrottleLimit** parameter limits the

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

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: System.Management.Automation.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Core
5-
ms.date: 04/26/2024
5+
ms.date: 04/23/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/where-object?view=powershell-7.5&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Where-Object
@@ -248,32 +248,41 @@ particular version of Windows.
248248
Starting in Windows PowerShell 3.0, there are two different ways to construct a `Where-Object`
249249
command.
250250

251-
- **Script block**. You can use a script block to specify the property name, a comparison operator,
251+
- **Script block syntax**. You can use a script block to specify the property name, a comparison operator,
252252
and a property value. `Where-Object` returns all objects for which the script block statement is
253253
true.
254254

255-
For example, the following command gets processes in the `Normal` priority class, that is,
256-
processes where the value of the **PriorityClass** property equals `Normal`.
255+
For example, the following command gets processes where the value of the **PriorityClass**
256+
property equals `Normal`.
257257

258-
`Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}`
258+
```powershell
259+
Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}
260+
```
259261

260262
All PowerShell comparison operators are valid in the script block format. For more information,
261-
see [about_Comparison_Operators](About/about_Comparison_Operators.md).
263+
see [about_Comparison_Operators](./About/about_Comparison_Operators.md).
262264

263-
- **Comparison statement**. You can also write a comparison statement, which is much more like
264-
natural language. Comparison statements were introduced in Windows PowerShell 3.0.
265+
- **Simplified syntax**. To enable the simiplified syntax, `Where-Object` includes 31 swicth
266+
parameters that represent the comparison operators. The simplified syntax is easier to read and
267+
write than the script block syntax. You can combine one of the switch parameters with the
268+
**Property** and **Value** parameters to create a command that filters objects based on the values of
269+
their properties.
265270

266271
For example, the following commands also get processes that have a priority class of `Normal`.
267272
These commands are equivalent and you can use them interchangeably.
268273

269-
`Get-Process | Where-Object -Property PriorityClass -EQ -Value "Normal"`
274+
```powershell
275+
Get-Process | Where-Object -Property PriorityClass -Value Normal -EQ
276+
Get-Process | Where-Object PriorityClass -EQ Normal
277+
```
270278

271-
`Get-Process | Where-Object PriorityClass -EQ "Normal"`
279+
As shown in the example, the parameter names **Property** and **Value** are optional. The
280+
**Property** parameter is a positional parameter mapped to position `0`. The **Value** parameter
281+
is a positional parameter mapped to position `1`. The switch parameter, used to specify the
282+
comparison, can be used in any position.
272283

273-
Starting in Windows PowerShell 3.0, `Where-Object` adds comparison operators as parameters in a
274-
`Where-Object` command. Unless specified, all operators are case-insensitive. Before Windows
275-
PowerShell 3.0, the comparison operators in the PowerShell language were only usable in script
276-
blocks.
284+
The simplfied syntax was introduced in Windows PowerShell 3.0. For more information, see
285+
[about_Simplified_Syntax](About/about_Simplified_Syntax.md).
277286

278287
When you provide a single **Property** to `Where-Object`, the cmdlet treats the value of the
279288
property as a boolean expression. When the value of the property's **Length** isn't zero, the
@@ -285,7 +294,7 @@ The previous example is functionally equivalent to:
285294
- `('hi', '', 'there') | Where-Object { $_.Length -gt 0 }`
286295

287296
For more information about how PowerShell evaluates booleans, see
288-
[about_Booleans](About/about_Booleans.md).
297+
[about_Booleans](about/about_Booleans.md).
289298

290299
## EXAMPLES
291300

@@ -400,9 +409,9 @@ The example uses the script block command format. Logical operators, such as `-a
400409
`Where-Object` command.
401410

402411
- For more information about PowerShell logical operators, see
403-
[about_Logical_Operators](About/about_Logical_Operators.md).
412+
[about_Logical_Operators](./About/about_logical_operators.md).
404413
- For more information about the Updatable Help feature, see
405-
[about_Updatable_Help](About/about_Updatable_Help.md).
414+
[about_Updatable_Help](./About/about_Updatable_Help.md).
406415

407416
## PARAMETERS
408417

@@ -1188,7 +1197,7 @@ PowerShell includes the following aliases for `Where-Object`:
11881197
Starting in Windows PowerShell 4.0, `Where` and `ForEach` methods were added for use with
11891198
collections.
11901199

1191-
You can read more about these methods here [about_Arrays](About/about_Arrays.md)
1200+
You can read more about these methods here [about_Arrays](./About/about_Arrays.md)
11921201

11931202
## RELATED LINKS
11941203

@@ -1208,4 +1217,4 @@ You can read more about these methods here [about_Arrays](About/about_Arrays.md)
12081217

12091218
[Tee-Object](../Microsoft.PowerShell.Utility/Tee-Object.md)
12101219

1211-
[about_Booleans](About/about_Booleans.md)
1220+
[about_Booleans](./About/about_Booleans.md)

0 commit comments

Comments
 (0)