PowerShell Encoding Mismatch Caused 580 Bytes of Corrupt Data in Automation Log

A developer's automated quality-gate system began failing because it could not read an expected value from a daily evidence file. On inspecting the file in hex view, each character appeared separated by NUL bytes, revealing a UTF-16 encoding embedded within a UTF-8 file. The root cause was PowerShell 5.1's Tee-Object command, which writes UTF-16 by default, while the file's header had been written using Set-Content with UTF-8 encoding. This mismatch left 580 of the file's 2,198 bytes as NUL or whitespace characters, making the data unreadable to downstream systems. The developer resolved the issue by replacing Tee-Object with Out-File, which allows explicit encoding control, and noted that similar encoding conflicts can silently corrupt log pipelines in any data-processing workflow.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in