Moerwald
Moerwald

Reputation: 11294

Print all parameters passed to a cmdlet

Is there an easy way to get all paramters of a PowerShell cmdlet as a hashtable? I want the ability to dump all paramters via Write-Verbose (for debugging issues). What I want to do:

  Function verb-noun {
      Param($p1, $p2, $p2)

      $parameters = ... # Get all parameters as hash
      $parameters.Keys | % { Write-Verbose "$_=$parameters.Item($_)" } 
      ...
  }

Upvotes: 2

Views: 1362

Answers (1)

Martin Brandl
Martin Brandl

Reputation: 58981

You are looking for the automatic $PSBoundParameters variable which is a dictionary containing all bound parameter (parameters that you pass to the function)

Upvotes: 5

Related Questions