Easier Parameter Attributes in PowerShell v3

by Oct 3, 2012

In PowerShell v2, to declare a function parameter as mandatory, you would decorate the parameter like this:

param(
  [Parameter(Mandatory=$true)]
  $p
)
in PowerShell v3, those attributes default to $true, so you get away with:
param(
  [Parameter(Mandatory)]
  $p
)

Twitter This Tip! ReTweet this Tip!