unreadable output file in powershell

If you redirect a not-completly-string output (like a spfile) to a file in powershell, you may not see the same in the file as in the output

  • without redirection
    PS C:\> Select-String "compatible" .\spfileDB01.ora
  • with redirection
    PS> Select-String "compatible" .\spfileDB01.ora > compatible.txt
    PS> vim -b .\compatible.txt
  • With redirection and conversion to ascii
    PS> Select-String "compatible" .\spfileDB01.ora | 
      Out-File -Encoding ASCII .\compatible.txt
    PS> vim .\compatible.txt

With Out-File (instead of >), you can specify the encoding, which does the trick

Published by

Laurent Schneider

Oracle Certified Master

Leave a Reply