title: Email output of script
body: <p>I'm trying to email the output of a script, but I'm pretty sure I have my syntax all mixed up.</p>
  
  <p>Here what I'd like:</p>
  
  <pre><code>send-mailmessage -from " Daily Check &lt;server@company.com&gt;" -to "Admin &lt;admin@company.com&gt;" -subject "Daily Check: Server Times" -body $output -priority High -dno onSuccess, onFailure -smtpServer mail.company.com
  
  $output=
  
  {
  ForEach ($server in $servers) {
      $time = ([WMI]'').ConvertToDateTime((gwmi win32_operatingsystem -computername $server).LocalDateTime)
      $server + '  ' + $time
      }        
  }
  $servers = 'SVRADFS365', 'SVRAPP01', 'SVRCAS01', 'SVRCAS02
  </code></pre>
  
  <p>The original script whose output I want emailed:</p>
  
  <pre><code>$servers = 'server1', 'server2', 'server3', 'server4'
  ForEach ($server in $servers) {
      $time = ([WMI]'').ConvertToDateTime((gwmi win32_operatingsystem -computername $server).LocalDateTime)
      $server + '  ' + $time
  }
  </code></pre>