title: PowerShell - SupportsShouldProcess within script property
body: <p>I'm getting a null expression when I try to access a variable within the ShouldProcess script-block. This is what I have in a script method:</p>
  
  <pre><code>$scaObject = [PerfWorker.CmdLets.PSDbInfoFactory]::GetPSDbInfo($info, $false)
  $oracleObj = [PerfWorker.CmdLets.OracleParamsDto]$scaObject
  Add-Member -InputObject $oracleObj -MemberType ScriptMethod -Name DropSchemas -Value {      
      $oraWorker = [PerfWorker.CmdLets.PSDbOracleInfo]$this.DbWorker                         
      $args | foreach {                                                                       
          #Start getting error "You cannot call a method on a null-valued expression" from line below
          if($psCmdLet.ShouldProcess(                                       
              "Delete Oracle Schema $_ on $($this.Hostname)? This action cannot be undone!",  
              "Delete Schema?"))                                                              
          {
              $oraWorker.DropS3DSchemas($_)                                       
          }                                                                               
      }
  }
  </code></pre>
  
  <p>If I remove the <code>$psCmdlet.ShouldProcess</code> block and just call the <code>$oraWorker.DropS3DSchemas()</code> method, then everything works fine.</p>