How to evaluate PowerShell script inputed from stdin
The following would work:
Use a scriptblock:
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'
so the $input variable isn't expanded, and the string '$input' is passed to iex.
Both of these give me "12".
Just use -
as a source file "name":
echo "echo 12;" | powershell -noprofile -noninteractive -