title: How can I chain Export-CSV to Send-MailMessage without having to save the CSV to disk in PowerShell?
body: <p>I would like to email a list of AD users as a CSV but I don't want to have to save the CSV to disk before I email it.</p>
  
  <p>Here is the code that gets me the data:</p>
  
  <pre><code>get-aduser -filter * -properties Telephonenumber |
  where Telephonenumber -ne $Null | 
  select givenname, surname, telephonenumber | 
  sort surname
  </code></pre>
  
  <p>Now I want to add on something like:</p>
  
  <pre><code>| Export-Csv | 
  Send-MailMessage -From HelpDesk@company.com -to someone@company.com -subject "Outlook address book export" -SmtpServer EdgeTransport
  </code></pre>
  
  <p>Is there anyway to add the CSV data as an attachment in memory without saving the file to the file system?</p>