WinRb / winrm-elevated

Runs PowerShell commands as elevated over Windows Remote Management (WinRM) via a scheduled task
Apache License 2.0
27 stars 17 forks source link

Fix encoding corruptions #43

Closed fmang closed 3 years ago

fmang commented 4 years ago

When running a simple echo é through winrm-elevated, the output I get back is badly corrupted. There are actually two corruptions:

  1. We upload the script to execute as a UTF-8 file, but Windows reads it as ANSI because that’s its default encoding.
  2. When cmd.exe writes the output files, its default encoding is OEM, but PowerShell reads them later as ANSI.

Adding a BOM to the beginning of the input script fixes 1, and explicity telling PowerShell to use the OEM encoding when reading the output file fixes 2.

Characters not representable as ANSI or OEM are transliterated.