mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
force Windows to always use preamble-free UTF8 input encoding (#22934)
* fixes #15770 * When running under the UTF-8 codepage, Powershell subprocesses will fail (eg, Start-Job, others) if the input encoding is using the default BOM preamble. This fix forces it to use no preamble in leaf_exec and win_shell, and includes tests to verify that Start-Job works.
This commit is contained in:
parent
cd662efd2b
commit
e084e8809e
4 changed files with 26 additions and 0 deletions
|
@ -124,6 +124,9 @@ Function Run($payload) {
|
|||
$ps.AddCommand("Out-Null") | Out-Null
|
||||
}
|
||||
|
||||
# force input encoding to preamble-free UTF8 so PS sub-processes (eg, Start-Job) don't blow up
|
||||
$ps.AddStatement().AddScript("[Console]::InputEncoding = New-Object Text.UTF8Encoding `$false") | Out-Null
|
||||
|
||||
$ps.AddStatement().AddScript($entrypoint) | Out-Null
|
||||
|
||||
$output = $ps.Invoke()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue