title: How do I add timestamps to individual lines of PowerShell & output?
body: <p>How, if at all, is it possible to add timestamps to each line of an output generated by the <code>&amp;</code> PowerShell operator?</p>
  
  <p>Example:</p>
  
  <pre><code>PS H:\&gt; $result = &amp; ping 192.168.1.1
  PS H:\&gt; echo $result
  
  Pinging 192.168.1.1 with 32 bytes of data:
  Reply from 192.168.1.1: bytes=32 time=104ms TTL=250
  Reply from 192.168.1.1: bytes=32 time=106ms TTL=250
  Reply from 192.168.1.1: bytes=32 time=102ms TTL=250
  Reply from 192.168.1.1: bytes=32 time=102ms TTL=250
  Ping statistics for 192.168.1.1:
  Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  Approximate round trip times in milli-seconds:
  Minimum = 102ms, Maximum = 106ms, Average = 103ms
  </code></pre>
  
  <p>Desired result:</p>
  
  <pre><code>PS H:\&gt; echo $result
  
  2014-12-08T14:45:48.8898125+00:00:Pinging 192.168.1.1 with 32 bytes of data:
  2014-12-08T14:45:48.8932661+00:00:Reply from 192.168.1.1: bytes=32 time=104ms TTL=250
  2014-12-08T14:45:48.9233451+00:00:Reply from 192.168.1.1: bytes=32 time=106ms TTL=250
  2014-12-08T14:45:48.9765438+00:00:Reply from 192.168.1.1: bytes=32 time=102ms TTL=250
  2014-12-08T14:45:49.0233105+00:00:Reply from 192.168.1.1: bytes=32 time=102ms TTL=250
  2014-12-08T14:45:49.0233201+00:00:
  2014-12-08T14:45:49.0238753+00:00:Ping statistics for 192.168.1.1:
  2014-12-08T14:45:49.0239210+00:00:    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  2014-12-08T14:45:49.0233318+00:00:Approximate round trip times in milli-seconds:
  2014-12-08T14:45:49.0237209+00:00:    Minimum = 102ms, Maximum = 106ms, Average = 103ms
  </code></pre>
  
  <p>I know how to split / join a PowerShell array, but this can only happen AFTER the <code>&amp;</code> operator completes. I am looking for more realtime-like solution, where timestamps are added to the output while the &amp; operator is running.</p>
  
  <p>By the way, the timestamp itself is <code>$($(Get-Date -Format o) + ":")</code></p>