title: Powershell Out-File: Force encoding to Ascii
body: <p>I am attempting to normalize a set of TAB-delimited logfiles using Powershell.</p>
  
  <p>Here is the current script:</p>
  
  <pre><code>(Get-ChildItem *.csv) |%{
  #Store the name of the file &amp; date
  $Name = $_.basename
  $FileDate = $_.CreationTime
  #Prepends the following to each message: unique Identifer, Hostname, date
  (Get-Content $_.fullname) -replace "^","AR-LOG|$Name|$FileDate|"|
  #Replaces the TAB delimeter with a Pipe delimeter
  Foreach-Object {$_ -replace '   ','|'}  |
  #Appends the resulting message in ascii
  Out-File -append -FilePath normalized.log -Encoding ascii
  </code></pre>
  
  <p>A snippet of the input &amp; output can be seen here: </p>
  
  <p><a href="http://pastebin.com/uaQadYUC" rel="nofollow">http://pastebin.com/uaQadYUC</a></p>
  
  <p>How can I force the output file to be ascii and not some type of unicode?</p>
  
  <p>***Edit: Further troubleshooting reveals that the input files are actually windows-1252 encoded, which apparently Get-Content cannot handle natively(?)</p>