File tree Expand file tree Collapse file tree
7.4/Microsoft.PowerShell.Core
7.5/Microsoft.PowerShell.Core
7.6/Microsoft.PowerShell.Core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22external help file : System.Management.Automation.dll-Help.xml
33Locale : en-US
44Module Name : Microsoft.PowerShell.Core
5- ms.date : 04/26/2024
5+ ms.date : 04/13/2025
66online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.4&WT.mc_id=ps-gethelp
77schema : 2.0.0
88title : ForEach-Object
@@ -457,23 +457,10 @@ Output: 5
457457
458458### Example 17: Passing variables in nested parallel scriptblocks
459459
460- You can create a variable outside a ` ForEach-Object -Parallel ` scoped scriptblock and use
461- it inside the scriptblock with the ` Using: ` scope modifier.
462-
463- ``` powershell
464- $test1 = 'TestA'
465- 1..2 | ForEach-Object -Parallel {
466- $Using:test1
467- }
468- ```
469-
470- ``` Output
471- TestA
472- TestA
473- ```
474-
475- Beginning in PowerShell 7.2, you can create a variable inside a ` ForEach-Object -Parallel ` scoped
476- scriptblock and use it inside a nested scriptblock.
460+ You can create a variable outside a ` ForEach-Object -Parallel ` scoped scriptblock and use it inside
461+ the scriptblock with the ` Using: ` scope modifier. Beginning in PowerShell 7.2, you can create a
462+ variable inside a ` ForEach-Object -Parallel ` scoped scriptblock and use it inside a nested
463+ scriptblock.
477464
478465``` powershell
479466$test1 = 'TestA'
Original file line number Diff line number Diff line change 22external help file : System.Management.Automation.dll-Help.xml
33Locale : en-US
44Module Name : Microsoft.PowerShell.Core
5- ms.date : 04/26/2024
5+ ms.date : 04/13/2025
66online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.5&WT.mc_id=ps-gethelp
77schema : 2.0.0
88title : ForEach-Object
@@ -457,23 +457,10 @@ Output: 5
457457
458458### Example 17: Passing variables in nested parallel scriptblocks
459459
460- You can create a variable outside a ` ForEach-Object -Parallel ` scoped scriptblock and use
461- it inside the scriptblock with the ` Using: ` scope modifier.
462-
463- ``` powershell
464- $test1 = 'TestA'
465- 1..2 | ForEach-Object -Parallel {
466- $Using:test1
467- }
468- ```
469-
470- ``` Output
471- TestA
472- TestA
473- ```
474-
475- Beginning in PowerShell 7.2, you can create a variable inside a ` ForEach-Object -Parallel ` scoped
476- scriptblock and use it inside a nested scriptblock.
460+ You can create a variable outside a ` ForEach-Object -Parallel ` scoped scriptblock and use it inside
461+ the scriptblock with the ` Using: ` scope modifier. Beginning in PowerShell 7.2, you can create a
462+ variable inside a ` ForEach-Object -Parallel ` scoped scriptblock and use it inside a nested
463+ scriptblock.
477464
478465``` powershell
479466$test1 = 'TestA'
Original file line number Diff line number Diff line change 22external help file : System.Management.Automation.dll-Help.xml
33Locale : en-US
44Module Name : Microsoft.PowerShell.Core
5- ms.date : 04/26/2024
5+ ms.date : 04/13/2025
66online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.6&WT.mc_id=ps-gethelp
77schema : 2.0.0
88title : ForEach-Object
@@ -457,23 +457,10 @@ Output: 5
457457
458458### Example 17: Passing variables in nested parallel scriptblocks
459459
460- You can create a variable outside a ` ForEach-Object -Parallel ` scoped scriptblock and use
461- it inside the scriptblock with the ` Using: ` scope modifier.
462-
463- ``` powershell
464- $test1 = 'TestA'
465- 1..2 | ForEach-Object -Parallel {
466- $Using:test1
467- }
468- ```
469-
470- ``` Output
471- TestA
472- TestA
473- ```
474-
475- Beginning in PowerShell 7.2, you can create a variable inside a ` ForEach-Object -Parallel ` scoped
476- scriptblock and use it inside a nested scriptblock.
460+ You can create a variable outside a ` ForEach-Object -Parallel ` scoped scriptblock and use it inside
461+ the scriptblock with the ` Using: ` scope modifier. Beginning in PowerShell 7.2, you can create a
462+ variable inside a ` ForEach-Object -Parallel ` scoped scriptblock and use it inside a nested
463+ scriptblock.
477464
478465``` powershell
479466$test1 = 'TestA'
You can’t perform that action at this time.
0 commit comments