title: powershell mandatory parameter throws error when null
body: <p>I am confused about how to do error handling in the case that a mandatory variable remains null.</p>
  
  <pre><code>function parse-com{
      [CmdletBinding()]
      Param
      (
          [Parameter(Mandatory=$True)]
          [string[]]$list
       )
  ...
  </code></pre>
  
  <p>In this case if no argument is passed for $list then I am prompted for it, but if I just hit enter (pass a null to $list) then I throw an error. What I would rather do is throw a usage statement and/or exit gracefully. Example...</p>
  
  <pre><code>PS C:\Users\memyself&gt; parse-com
  cmdlet parse-com at command pipeline position 1
  Supply values for the following parameters:
  list[0]: 
  parse-com : Cannot bind argument to parameter 'list' because it is an empty array.
  At line:1 char:1
  + parse-com
  + ~~~~~~~~~
      + CategoryInfo          : InvalidData: (:) [parse-com], ParameterBindingValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,parse-com
  </code></pre>