PowerShell 7.3 Get-Content Not Reading Files with BOM Properly
I'm having trouble reading UTF-8 encoded files with a Byte Order Mark (BOM) using PowerShell 7.3... When I use `Get-Content` to read these files, the output appears corrupted, displaying the BOM characters instead of the expected text. I've tried using the `-Encoding` parameter to specify `UTF8`, but it seems to still include the BOM characters in the output. Hereโs the command Iโm using: ```powershell $content = Get-Content -Path 'C:\path\to\file.txt' -Encoding UTF8 ``` When I output `$content`, the beginning of the string includes `รฟรฟ`, which are the BOM characters. I also tried using `-Raw` to read the entire content at once but the scenario continues: ```powershell $content = Get-Content -Path 'C:\path\to\file.txt' -Raw -Encoding UTF8 ``` I've looked into alternative approaches like using `[System.IO.File]::ReadAllText()` but I want to stick with `Get-Content` for simplicity and consistency. Is there a way to correctly read the file without the BOM characters showing up in the output? Any guidance on handling this specific case would be greatly appreciated. This is for a web app running on Windows 11.