What is the Powershell analogue of $@ used to call another command?
You want to use argument splatting which is new in PowerShell 2.0. The variable used for splatting can be either an array (args are bound positionally) or a hashtable (keys map to parameter names and their values provide the argument). If you don't declare any parameters then use @args
. The problem with attempting to use $args
is that it will be sent as an array to the first parmeter rather than splatted across all the parametets. However many folks do declare parameter. In this case you want to use @PSBoundParameters e.g.:
foo @PSBoundParameters