Question Details

No question body available.

Tags

powershell

Answers (1)

Accepted Answer Available
Accepted Answer
January 23, 2026 Score: 1 Rep: 453,905 Quality: High Completeness: 80%

No, as of PowerShell v7.5.x there is no support for using named arguments in .NET method calls, unlike in C#.

GitHub issue #13307 is a proposal from 2020 to change that, but it has stalled.


As a (suboptimal) workaround, you could design your methods to accept a single hashtable instead of distinct parameters, in which case you could do something like:

class A {
  static method ([hashtable] $params) {
    $params | Out-Host
  }
}

[A]::method(@{ a="a"; b="b"})

I don't know how that would perform, however, and needing to ensure inside the method body that the appropriate entries are present in a given hashtable (both in terms of completeness and type) requires additional effort.

Also, the usual approach to discovering a method's parameters by submitting [A]::method (i.e. accessing the method without parentheses) won't reveal the required hashtable entries, it'll just report static void method(hashtable params)