Author Posts

August 28, 2018 at 2:40 pm

I happened to notice that when saving output with ">" or out-file, the result is a unix text file with no carriage returns, just "`n", not "`r`n" (EDIT: I was wrong). And Infoblox happens to not like unix text files for csv importing. I know how to work around it, but I found it surprising.

August 28, 2018 at 2:52 pm

Specifies the type of character encoding used in the file. The acceptable values for this parameter are:

  • Unknown
  • String
  • Unicode
  • BigEndianUnicode
  • UTF8
  • UTF7
  • UTF32
  • Default
  • OEM

Unicode is the default.
"Default" uses the encoding of the system's current ANSI code page.
"OEM" uses the current original equipment manufacturer code page identifier for the operating system.


If you are trying to export a csv, why wouldn't you use export-csv vs out-file?

August 28, 2018 at 3:32 pm

Yes, export-csv outputs windows text, or "ascii". It depends on the situation. Sometimes I don't have an object to being with. The default encoding seems to be "Unicode UTF-16 Little-Endian" for out-file and ">", according to "Get-FileEncoding" (from oem and default seem to be the same as ascii. Default isn't the default.

August 28, 2018 at 3:54 pm

If you're doing anything more than the simplest of text output, I would not recommend using the redirection operators to output to files. They're simplistic and are good for quick short use, not meant for anything even remotely complicated.

Instead, pipe your output into Add- or Set-Content, which will allow you to properly handle encoding and most other things you'll need without issue.

August 28, 2018 at 4:35 pm

To me, this is just another bug or sub-optimal feature that's changed in PS 6.

EDIT: PS 6 uses UTF8-NO-BOM, which looks a lot like ANSI/ASCII:

EDIT: Yes, the carriage returns don't matter, it's the ansi/ascii/utf-8 encoding. Some sites say unicode isn't an encoding, it's a character set. 5.1 Out-File doesn't even make unix text. It makes utf-16.