title: Converting to and from Base64 in Powershell 5.1
body: <p>I've found a couple of resources (including <a href="https://stackoverflow.com/questions/35334928/convert-base64-string-to-file">Convert base64 string to file</a>, which is practically a duplicate here since it's one of the resources I used to build this) but I can't seem to get it working.</p>
  <p>I've got the following code (roughly - obviously it's stripped down,) and I can verify most of the steps of the process as per the comments.</p>
  <pre><code>$pic = Get-Content 'testpic.png'
  # $pic looks like a binary dump.
  
  $picBytes = [System.Text.Encoding]::Unicode.GetBytes($pic)
  $ $picBytes is an array of bytes. Quite spammy.
  
  $picEncoded = [Convert]::ToBase64String($picBytes)
  # $picEncoded is indeed a Base64 string. Halfway there!
  
  $picDecoded = [Convert]::FromBase64String($picEncoded)
  # Also an array of bytes. I'm assuming they're right for now...
  
  $outFile = &quot;pic.png&quot;
  [IO.File]::WriteAllBytes($outFile,$picDecoded)
  # but I get no output file and no error?
  </code></pre>
  <p>What am I missing here? For what it's worth, I'm willing to look at other solutions - but the Base64 is somewhat important (since I'm storing the data in the script.)</p>