Need the get-content command output in UTF8 no bom

Hi Community,

i am using this command and the output is being getting generated in UTF-8 bom.
Get-Content -Path "$logFile" -Encoding UTF8.

I need the output to be in the UTF-8 No bom. Any way out there ?

Use PowerShell 7.4.

Get-Content -Encoding utf8NoBOM

isnt there something like this in powershell 5?

Not built in - no. :man_shrugging:t3:

What is actually the issue? Could you show how the output looks like? (formatted as code please)

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

Lots of work arounds here

I would pay close attention to mklements answer and comments, he is incredibly knowledgeable about intimate details of powershell.

Just in case others might find this useful:

The UTF-8 BOM is a sequence of bytes at the start of a text stream ( 0xEF, 0xBB, 0xBF ) that allows the reader to more reliably guess a file as being encoded in UTF-8. Normally, the BOM is used to signal the endianness of an encoding, but since endianness is irrelevant to UTF-8, the BOM is unnecessary.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.