我想在 PowerShell 中评估来自 StdIn 的内容,如下所示:
echo "echo 12;" | powershell -noprofile -noninteractive -command "$input | iex"
输出:
echo 12;
不幸的是,$input
不是一个字符串,而是一个System.Management.Automation.Internal.ObjectReader
,它iex
不能按预期工作......因为这个工作正常:
powershell -noprofile -noninteractive -command "$command = \"echo 12;\"; $command | iex"
输出:
12