title: Why can I not test for ParameterBindingValidationException in Pester?
body: <p>Given a function that has validation for a parameter:</p>
  <pre><code>function Test-Validation {
      [CmdletBinding()]
      param (
          [Parameter()]
          [ValidateScript({
              # Add some validation that can throw.
              if (-not (Test-Path -Path $_ -PathType Container)) {
                  throw &quot;OutDir must be a folder path, not a file.&quot;
              }
              return $true
          })]
          [System.String]
          $Folder
      )
      Process {
          $Folder + &quot; is a folder!&quot;
      }
  }
  </code></pre>
  <p>We should be able to check the error type and set that as the <code>ExpectedType</code> in a Pester Test.</p>
  <pre><code>Test-Validation -Folder C:\Temp\file.txt
  Test-Validation : Cannot validate argument on parameter 'Folder'. OutDir must be a folder path, not a file.
  At line:1 char:17
  + Test-Validation C:\Temp\file.txt
  +                 ~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidData: (:) [Test-Validation], ParameterBindingValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Test-Validation
  
  $Error[0].Exception.GetType()
  
  IsPublic IsSerial Name                                     BaseType
  -------- -------- ----                                     --------
  False    True     ParameterBindingValidationException      System.Management.Automation.ParameterBindingException
  </code></pre>
  <p>However, when testing in Pester, the test fails because it cannot find the type.</p>
  <pre><code>$ShouldParams = @{
      Throw           = $true
      ExpectedMessage = &quot;Cannot validate argument on parameter 'OutDir'. OutDir must be a folder path, not a file.&quot;
      ExceptionType   = ([System.Management.Automation.ParameterBindingValidationException])
  }
  { Test-Validation -Folder C:\Temp\file.txt } | Should @ShouldParams
  
  # Result
  RuntimeException: Unable to find type [System.Management.Automation.ParameterBindingValidationException].
  </code></pre>
  <p>How can I fix this test so that I know I am not just catching any exception type?</p>