title: Script to export to excel
body: <p>I Have below script:-- looking for help to convert the output to excel format</p>
  
  <pre><code>$servers = get-content “c:\list.txt”
  foreach ($server in $servers)
  {
  $server
  $command = “quser /server:” + $server
  invoke-expression $command 
  }
  </code></pre>
  
  <p>when executed getting in below format the output.</p>
  
  <pre><code>server1
   USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
   Vdw231                ica-tcp#8           7  Active          .  11/5/2012 10:40 AM
   Vdw232                ica-tcp#60         16  Active      16:18  11/5/2012 2:22 PM
   Vdw233                ica-tcp#71          3  Active          .  11/6/2012 6:10 AM
   Vdw234                ica-tcp#72          1  Active          3  11/6/2012 6:59 AM
   Vdw235                ica-tcp#73          5  Active          .  11/6/2012 6:59 AM
   Vdw236                rdp-tcp#74          2  Active          .  11/6/2012 7:07 AM
  server2
   USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
   Vdw210                ica-tcp#44         14  Active      13:50  11/5/2012 9:03 AM
   Vdw211                ica-tcp#67          6  Active          .  11/6/2012 1:56 AM
   Vdw212                ica-tcp#70          1  Active         45  11/6/2012 6:34 AM
   Vdw213                ica-tcp#72          9  Active         25  11/6/2012 6:53 AM
   Vdw214  
  server3
   USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
   Vdw215                rdp-tcp#131         1  Active         19  11/5/2012 1:42 AM
   Vdw216                rdp-tcp#132         4  Active         17  11/5/2012 2:06 AM
   Vdw217                rdp-tcp#143         6  Active          .  11/6/2012 3:31 AM
  </code></pre>
  
  <p>My requirement is i wanted to convert this output to excel format for submitting to management. Below is the excel format that i am thinking...to have from above script...</p>
  
  <p><img src="https://i.stack.imgur.com/s25Jd.jpg" alt="enter image description here"></p>