Skip to content

Commit 70c2c01

Browse files
authored
Merge pull request #6 from santisq/5-invoke-parallel-should-use-$pscmdlet-instead-of-$executioncontext
Change `$ExecutionContext` for `$PSCmdlet` on `$using:` statements
2 parents 4a6b473 + 1881de8 commit 70c2c01

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

PSParallelPipeline/PSParallelPipeline.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSParallelPipeline.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.0.2'
15+
ModuleVersion = '1.0.3'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

PSParallelPipeline/PSParallelPipeline.psm1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ function Invoke-Parallel {
156156

157157
$key = [Convert]::ToBase64String([Encoding]::Unicode.GetBytes($varText.ToLower()))
158158
if(-not $usingParams.ContainsKey($key)) {
159-
$usingParams.Add($key, $ExecutionContext.SessionState.PSVariable.GetValue($varPath))
159+
# Huge thanks to SeeminglyScience again and again! The function must use
160+
# `$PSCmdlet.SessionState` instead of `$ExecutionContext.SessionState`
161+
# to properly refer to the caller's scope.
162+
$usingParams.Add($key, $PSCmdlet.SessionState.PSVariable.GetValue($varPath))
160163
}
161164
}
162165

0 commit comments

Comments
 (0)