更新时间:2023-11-18 08:26:52
以下方法可行:
使用脚本块:
echo "echo 12;" | powershell -noprofile -noninteractive -command { $input | iex }
或者使用单引号来避免字符串插值:
Or use single quotes to avoid the string interpolation:
echo "echo 12;" | powershell -noprofile -noninteractive -command '$input | iex'
所以 $input 变量没有被扩展,字符串 '$input' 被传递给 iex.
so the $input variable isn't expanded, and the string '$input' is passed to iex.
这两个都给我12".