wrapper is supposed to just call delegate, forwarding the arguments that were passed to wrapper.
Given
.\wrapper.ps1 1 2
When delegate.ps1 contents:
param($one, $two)
write-host "one=$one and two=$two"
Then expect output to be:
one=1 and two=2
wrapper.ps1 contents:
.\delegate # How do I forward all args passed to this wrapper script to the delegate script?
If I try the following implementation of wrapper.ps1:
.\delegate $args
The output is incorrectly:
one=1 2 and two=
What you are looking for is Splatting
Use the @ symbol
.\delegate @args
PowerShell provides a ProxyCommand
class designed to make this easy. To generate the text of a wrapper function for a command, say MyCommand
, you would do
$wrapper = [System.Management.Automation.ProxyCommand]::Create((get-command MyCommand))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With