title: How to decode a Base64 string?
body: <p>I have a normal string in Powershell that is from a text file containing Base64 text; it is stored in <code>$x</code>. I am trying to decode it as such:</p>
  
  <pre><code>$z = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($x));
  </code></pre>
  
  <p>This works if <code>$x</code> was a Base64 string created in Powershell (but it's not). And this does not work on the <code>$x</code> Base64 string that came from a file, <code>$z</code> simply ends up as something like <code>䐲券</code>.</p>
  
  <p>What am I missing? For example, <code>$x</code> could be <code>YmxhaGJsYWg=</code> which is Base64 for <code>blahblah</code>.</p>
  
  <p>In a nutshell, <code>YmxhaGJsYWg=</code> is in a text file then put into a string in this Powershell code and I try to decode it but end up with <code>䐲券</code> etc.</p>