title: Using Powershell to Format Output of Array via a table for HTML EMail
body: <p>I'm attempting to build a table from an array and then place it into an email. I'm able to get the table to show the first item from the array, but can't get the rest of the items to be listed. I feel like I'm close, any ideas on what I may be missing.</p>
  
  <pre><code>$global:Report = "C:\TEMP\Scripts\PowerShell\ReadExcelFiles\File.csv"
  $UViolation = import-csv $global:Report -Delimiter '    ' | Where-Object {$_.Rules -eq "TESTTEXTINFILE"}
  $UserViolationDetails = New-Object System.Collections.ArrayList
  
  foreach ($item in $UViolation){
      if ($item.Destination -notcontains "HP ") {
      $UserViolationDetails += ,@($item.'User Name', $item.'Occurred (Endpoint)',$item.'IP Address',$item.'Computer Name',$item.Destination)
      }
  }
  $UserID = "USERID01"
  $events = $UserViolationDetails -match $UserID
  $count = 0
  foreach ($line in $events){
      $count++
      $table = @( @{'User ID'=$line[0]; 'DateTime'=$line[1]})
  }
  $count
  $table.ForEach({[PSCustomObject]$_}) | Format-Table -AutoSize
  
  $ol = New-Object -comObject Outlook.Application
  $mail = $ol.CreateItem(0) 
  $mail.To = "$global:UserReportsToEmail"
  $mail.cc = "EMAIL@DOMAIN.com"
  $mail.Subject = "mySubject" 
  $mail.HTMLBody = 
  "&lt;font color ='blue'&gt;&lt;b&gt;TESTING STUFFFF!&lt;/b&gt;&lt;/font&gt;&lt;br&gt;
  Text on a new line $UserID&lt;br&gt;$table"
  
  $inspector = $mail.GetInspector
  $inspector.Display()
  </code></pre>