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).
The Stream itself is $contactInfo.Get_Item("Photo"). I think I need to do something like this:
$br = new-object System.IO.BinaryReader $contactInfo.Get_Item("Photo")
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.
The type of the Stream object is Microsoft.Lync.Model.UCStream.
$contactInfo.Get_Item("Photo").GetType().Fullname. If it is a byte[] then just do thisSet-Content photo.jpeg $contactInfo.Get_Item("Photo") -Encoding Byte.$bytes | Set-Content photo.jpeg -enc byte.