我想评估Powershell中StdIn的内容,如下所示:
echo "echo 12;" | powershell -noprofile -noninteractive -command "$input | iex"
输出: echo 12;
不幸的是,$input它不是String,而是a System.Management.Automation.Internal.ObjectReader,它iex无法按预期方式工作...因为此代码正常工作:
powershell -noprofile -noninteractive -command "$command = \"echo 12;\"; $command | iex"
输出: 12