Search code examples
powershellstaticnamed-parameters

In PowerShell V2, how to have named parameters in a method on a static class?


The following didn't parse

[x.y]::z -Param1 some_value

Is this even possible?


Solution

  • When you're calling .NET methods from PowerShell, you use C# style comma separated args in parens syntax e.g.:

    [x.y]::z(some_value)
    

    In PowerShell, named parameters are a feature of PowerShell commands (functions, advanced functions, scripts, cmdlets, workflows) only.