Wrapper function in PowerShell: Pass remaining parameters

后端 未结 3 1504
旧巷少年郎
旧巷少年郎 2021-01-02 03:37

I’m trying to write a wrapper function in PowerShell that basically evaluates the first parameter and based on that runs a program on the computer. All the remaining paramet

3条回答
  •  灰色年华
    2021-01-02 03:54

    What you have written does work. Note that what is there is $args is the unnamed arguments that are over and above the parameters expected by the function.

    So if you call test as

    test -option "A" 1 2 3
    

    $args will have 1,2,3

    Note that if you call test as

    test -option "A" -other "B" 1 2 3
    

    $args will have -other,B,1,2,3

提交回复
热议问题