title: Error Handling method call on a null-valued expression
body: <p>I am getting the following non-terminating error in PowerShell.  I want to catch this and write-host a generic statement, rather than see the error.</p>
  
  <p>Here is the output:</p>
  
  <blockquote>
    <p>You cannot call a method on a null-valued expression. At C:\PowerShell
    Scripts\windowsUpdates.ps1:17 char:2
    +     $a = $key.GetValue("LastSuccessTime")
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRec    ordException
        + FullyQualifiedErrorId : InvokeMethodOnNull</p>
  </blockquote>
  
  <p>My catch statement is currently not "catching" this.</p>
  
  <p>Any help is appreciated.</p>