Add clean block to script block as a peer to begin, process, and end to allow easy resource cleanup (#15177)

This commit is contained in:
Dongbo Wang authored and GitHub committed 2021-10-11 14:49:09 -07:00
1 parent fa4bfb447e
commit a32700a1c1
30 files changed
+3055 -644

No files matched your search

@@ -2823,13 +2823,14 @@ function Get-PSImplicitRemotingClientSideParameters
$clientSideParameters = Get-PSImplicitRemotingClientSideParameters $PSBoundParameters ${8}
$scriptCmd = {{ & $script:InvokeCommand `
@clientSideParameters `
-HideComputerName `
-Session (Get-PSImplicitRemotingSession -CommandName '{0}') `
-Arg ('{0}', $PSBoundParameters, $positionalArguments) `
-Script {{ param($name, $boundParams, $unboundParams) & $name @boundParams @unboundParams }} `
}}
$scriptCmd = {{
& $script:InvokeCommand `
@clientSideParameters `
-HideComputerName `
-Session (Get-PSImplicitRemotingSession -CommandName '{0}') `
-Arg ('{0}', $PSBoundParameters, $positionalArguments) `
-Script {{ param($name, $boundParams, $unboundParams) & $name @boundParams @unboundParams }} `
}}
$steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
$steppablePipeline.Begin($myInvocation.ExpectingInput, $ExecutionContext)