Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Outputting PSBound Parameters
  2. foreach ($psbp in $PSBoundParameters)
  3. {
  4.     $messageBody += $psbp | out-string + "`r`n"
  5. }
  6.        
  7. foreach($psbp in $PSBoundParameters.GetEnumerator())
  8. {
  9.     "Key={0} Value={1}" -f $psbp.Key,$psbp.Value
  10. }
  11.  
  12.  
  13.  
  14.  
  15. function Get-PSBoundParameters
  16. {
  17.     [CmdletBinding()]    
  18.     Param($param1,$param2,$param3)
  19.  
  20.     foreach($psbp in $PSBoundParameters.GetEnumerator())
  21.     {
  22.             "Key={0} Value={1}" -f $psbp.Key,$psbp.Value
  23.     }
  24. }
  25.  
  26.  
  27. PS> Get-PSBoundParameters p1 p2 p3 | ft -a
  28.  
  29. Key=param1 Value=p1
  30. Key=param2 Value=p2
  31. Key=param3 Value=p3
  32.        
  33. function test
  34. {
  35.     param($a, $b)
  36.  
  37.     $psboundparameters.Values
  38.     $psboundparameters.Keys
  39. }
  40.  
  41.  
  42. test "Hello" "World"