Skip to content

Instantly share code, notes, and snippets.

@7cc
Created June 11, 2020 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7cc/bf7302fccd592d2c90408b21e5c5021d to your computer and use it in GitHub Desktop.
Save 7cc/bf7302fccd592d2c90408b21e5c5021d to your computer and use it in GitHub Desktop.
ScriptBlock_InvokeWithContext.ps1
$s = { param($a) $a+$b }
# success
$s.InvokeWithContext(
$null,
[psvariable[]]@([psvariable]::new("b", 3)),
2
) # 5
# fail
& $s -a 1 -b 2 # 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment