title: How can I write a binary Stream object to a file in PowerShell?
body: <p>I think I've tried every wrong way, and those few that don't just give ugly error messages write a garbled file that cannot be opened (you can still see the JFIF in it, but the jpeg magic smoke has been lost).</p>
  
  <p>The Stream itself is  $contactInfo.Get_Item("Photo"). I think I need to do something like this:</p>
  
  <pre><code>$br = new-object System.IO.BinaryReader $contactInfo.Get_Item("Photo")
  </code></pre>
  
  <p>But past that, I don't know what to do. I've tried Googling, but I'm not even sure what I'm looking for to be quite honest.</p>
  
  <p>The type of the Stream object is Microsoft.Lync.Model.UCStream.</p>