Skip to content

Powershell: Fix stdin handling with scripts

Stan Hu requested to merge sh-fix-powershell-stdin into main

!3728 (merged) added logic to add braces around a script only if the file were executed in a script, but the braces are actually needed when the script is passed in via stdin instead of a file. As the Powershell -help output says:

If the value of Command is a script block, the script block must
be enclosed in braces ({}). You can specify a script block only when
running PowerShell.exe in Windows PowerShell. The results of the
script block are returned to the parent shell as deserialized XML
objects, not live objects.

Relates to #29551 (closed)

Edited by Stan Hu

Merge request reports