I am making attempting to fix an app which has recently broken the ls
command, using a Powershell wrapper script. My wrapper must have the same name as the command it is invoking, so I'm using invoke-command
to call the original command.
# yarn broke 'ls'
function yarn() {
$modifiedArgs = @()
foreach ( $arg in $args ) {
if ( $arg -cmatch '^ls$' ) {
$arg = 'list'
}
$modifiedArgs = $modifiedArgs + $arg
}
invoke-command yarn -ArgumentList @modifiedArgs
}
However invoke-command
fails with
Invoke-Command : Parameter set cannot be resolved using the specified named parameters
How can I run the original command with the modified parameters?
Edit: I've also tried -ArgumentList (,$modifiedArgs)
per
Passing array to another script with Invoke-Command and I still get the same error.
Edit: Looks like invoke-command
is remoting only. I've also tried Invoke-Expression "& yarn $modifiedArgs"
but that runs the function itself.