title: PowerShell not printing to console
body: <p>I have the below code which retrieves the last users to login after a certain number of days. I want to stop logins that I don't care about from appearing in the list, such as when it shows that "LOCAL SERVICE" or "NETWORK SERVICE" has logged in. I also designed it so that repeats will be excluded.</p>
  
  <p>While trying to figure out why Powershell never thought <code>$Matches.AccountName</code> equaled "LOCAL SERVICE" or any of the other checks, I realized that powershell was refusing to print anything after this line</p>
  
  <pre><code>[void]($event.Message -match 'Account Name:\s{1,}(?&lt;AccountName&gt;.+)')
  </code></pre>
  
  <p>So I have three questions:</p>
  
  <ol>
  <li>Why won't PowerShell print anything in this location? </li>
  <li>What is wrong with my comparison that checks if AccountName is not equal to an account like "LOCAL SERVICE"? It always evaluates to false, thus allowing it to get added to the list</li>
  <li>This one is a little off topic but is there a name for what I am doing with the whole <code>$result = foreach($event in $events)</code> thing? I don't quite understand how it works or how it knows what to set each index of <code>$result</code> equal to</li>
  </ol>
  
  <pre class="lang-bsh prettyprint-override"><code>{
      $computer = $env:ComputerName
      if ($Days -eq $null) {
          $Days = Read-Host -prompt "Enter the number of days to go back"
      }
      $startDate = (Get-Date) - (New-TimeSpan -Day $Days)
      $events = Get-WinEvent -Computer $computer -FilterHashtable @{Logname='Security';ID=4672;StartTime=$startDate}
  
      [System.Collections.ArrayList]$arr = @() 
      $result = foreach ($event in $events) {
          [void]($event.Message -match 'Account Name:\s{1,}(?&lt;AccountName&gt;.+)')
          $Matches.AccountName.gettype()
          $Matches.AccountName
          "SYSTEM"
          $h = Read-Host -prompt "Stop here to see if anything printed"
          if ((-not ($arr.Contains($Matches.AccountName))) -and ($Matches.AccountName -ne "SYSTEM") -and ($Matches.AccountName -ne "LOCAL SERVICE") -and ($Matches.AccountName -ne "NETWORK SERVICE") -and ($Matches.AccountName -ne "Local Administrator")) {
              $arr.Add($Matches.AccountName) &gt; $null;
              [PSCustomObject]@{
                  AccountName = $Matches.AccountName;
                  Time = $event.timeCreated
              }
          }
      }
  </code></pre>