title: Simple PowerShell LastWriteTime compare
body: <p>I need a PowerShell script that can access a file's properties and discover the <em>LastWriteTime</em> property and compare it with the current date and return the date difference.</p>
  
  <p>I have something like this...</p>
  
  <pre><code>$writedate = Get-ItemProperty -Path $source -Name LastWriteTime
  </code></pre>
  
  <p>...but I can not cast the <em>LastWriteTime</em> to a "DateTime" datatype. It says, "Cannot convert "@{LastWriteTime=...date...}" to "System.DateTime".</p>