title: Powershell Security Log Get-EventLog
body: <p>I am trying to write something up in powershell and completely new to powershell, I need help. What I'm trying to do is get information from the Security Log. Specifically, the last login for users over the last two weeks. The code that I have so far is getting login's for the event ID 4624 based on the last 100 events. This is also returning not just users but computers as well. How can I limit the results to just users over a period of two weeks? Is this even possible?</p>
  
  <pre><code>$eventList = @()
  Get-EventLog "Security" -After $Date `
      | Where -FilterScript {$_.EventID -eq 4624 -and $_.ReplacementStrings[4].Length -gt 10} `
      | foreach-Object {
          $row = "" | Select UserName, LoginTime
          $row.UserName = $_.ReplacementStrings[5]
          $row.LoginTime = $_.TimeGenerated
          $eventList += $row
          }
  $eventList
  </code></pre>
  
  <p>EDIT: Solved with code </p>
  
  <pre><code>$Date = [DateTime]::Now.AddDays(-14)
  $Date.tostring("MM-dd-yyyy"), $env:Computername
  $eventList = @()
  Get-EventLog "Security" -After $Date `
      | Where -FilterScript {$_.EventID -eq 4624 -and $_.ReplacementStrings[4].Length -gt 10 -and $_.ReplacementStrings[5] -notlike "*$"} `
      | foreach-Object {
          $row = "" | Select UserName, LoginTime
          $row.UserName = $_.ReplacementStrings[5]
          $row.LoginTime = $_.TimeGenerated
          $eventList += $row
          }
  $eventList
  </code></pre>