title: Can I add title rows to a CSV export in Powershell?
body: <p>I'm exporting a report to a CSV in Powershell and I've been asked to provide three rows above the header row with title information, date of report, etc.</p>
  
  <p>If I export to CSV, i.e. <code>$reportdata | export-csv -notypeinformation fooreport.csv</code>, and then manually add the Title rows in Notepad, i.e.,</p>
  
  <pre><code>"Title"
  "Date of Report - XX-XX-XXXX"
   "***Important disclaimer about report***"
  "Column1","Column2","Column3", etc
  "Data1","Data2","Data3", etc
  </code></pre>
  
  <p>the CSV Report opens fine in Excel and the header and data rows are handled appropriately.</p>
  
  <p>However, when I attempt to do the following in PS,</p>
  
  <pre><code>#Create Report Header
  
  $date = get-date -format "dd MMM yyyy"
  
  $title = @"
  "Mailbox Send As, Full Permission and Send on Behalf Report"
  "$date"
  "***** Important Disclaimer - Only Explicit or Non-Inherited Permissions Are Displayed in this Report *****"
  "@
  
  $reportpath = "D:\dev\report.csv"
  
  $rep | export-csv -notypeinformation $reportpath
  
  $temp = gc $reportpath
  
  echo $title &gt; $reportpath
  
  $temp &gt;&gt; $reportpath
  </code></pre>
  
  <p>the CSV doesn't open properly in Excel and is improperly delimited (i.e., quotes and commas are visible in the cells), even though both files look identical in Notepad.</p>
  
  <p>Is there a way to do what I'm trying to do from Powershell without messing up the integrity of the CSV file? I'm wondering if I'm somehow removing some critical piece of information that signifies a header row in CSV files - since both files are identical, I'm wondering if I"m maybe missing a hidden or special character?</p>