title: Returning RecordCount from Get-WinEvent in Powershell
body: <p>I'm writing a PowerShell script that will count the number of records from the
  requested log with a specific id that have occurred in the last <code>$interval</code>
  seconds.  In the current version of the script, I am printing the <code>$log</code> of
  events returned, as well as the <code>RecordCount</code>.  However, the <code>RecordCount</code> is
  not printing.</p>
  
  <p>The current version of my script is:</p>
  
  <pre><code>$log_name = 'Application'
  $event_id = 1003
  $interval = (get-date).AddSeconds(-7200)  # Last 2 hours.
  $count = 0
  
  $log = Get-WinEvent -EA silentlycontinue `
                      -FilterHashTable @{ LogName=$log_name;
                                          StartTime=$interval;
                                          id=$event_id }
  
  $log
  $log.RecordCount
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>PS C:\temp&gt; .\log_monitor
  
  TimeCreated                   ProviderName                                             Id Message
  -----------                   ------------                                             -- -------
  01/25/2016 12:34:40 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:34:40 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:34:39 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:34:39 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:14:22 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:14:22 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:14:22 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:14:22 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:05:41 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:05:41 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:05:41 PM        Office Software Protection...                          1003 The Software Protection se...
  01/25/2016 12:05:41 PM        Office Software Protection...                          1003 The Software Protection se...
  
  
  PS C:\temp&gt;
  </code></pre>
  
  <p>Note that the <code>RecordCount</code> is not printing.</p>