小编san*_*ige的帖子

如何评估从stdin输入的Powershell脚本

我想评估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

powershell stdin

6
推荐指数
1
解决办法
3558
查看次数

标签 统计

powershell ×1

stdin ×1