I don't know much about powershell, but I would like to run another script from powershell, and also pass along all the unused arguments. In bash I am doing it this way (simplified):
MY_PARAM=$1
shift
python otherscript.py "$@"
I have tried many things in powershell but nothing worked. In my python script I either received "System.Object[]" (or "System.Collections.Generic.List`1[System.Object]") or all the arguments wrapped in a single string as the first argument (or various error messages of course). I have tried:
python otherscript.py $argsInvoke-Expression "python otherscript.py $args"- And in place of
$argsI have also tried using$MyInvocation.Lineor$MyInvocation.UnboundArguments
What is the proper syntax for this?
Update 1
As Mathias R. Jessen comments, invoking the python script from the "global scope" with python otherscript.py $args works as I would expect.
What I am actually trying to do, is call my python script from within a function:
param (
[string]$command = ""
)
function Invoke-Other() {
python otherscript.py $args
}
switch ($command) {
"foo" {
Invoke-Other $args
}
}
This is the setup, when I get a single, "wrapped" argument "bar baz", when I call my powershell script with .\myscript.ps1 foo bar baz.