Есть ли способ в powershell поймать ВСЕ именованные параметры

Рассмотрим это:

Function Foo 
{
    param(
        #????
    )
}

Я хочу позвонить Фу вот так:

Foo -Bar "test"

Без взрыва, что у меня нет указанного параметра $bar. Это возможно?:)

Обновление:

Я хочу, чтобы это работало:

Function IfFunctionExistsExecute
{
    param ([parameter(Mandatory=$true)][string]$func, [parameter(Mandatory=$false)][string]$args)
    begin 
    {
        #...
    }
    process
    {
        if(Get-Command $func -ea SilentlyContinue)
        {
            & $func $args   # the amperersand invokes the function instead of just printing the variable
        }
        else
        {
            # ignore
        }       
    }
    end
    {
        #...
    }
}


Function Foo
{
    param([string]$anotherParam)
    process 
    {
        $anotherParam
    }
}

IfFunctionExistsExecute Foo -Test "bar"

Это дает мне:

IfFunctionExistsExecute : A parameter cannot be found that matches parameter name 'Test'.
At C:\PSTests\Test.ps1:35 char:34
+ IfFunctionExistsExecute Foo -Test <<<<  "bar"
    + CategoryInfo          : InvalidArgument: (:) [IfFunctionExistsExecute], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,IfFunctionExistsExecute
5
задан Snake 6 July 2012 в 14:02
поделиться