The following steps will work:
Use script block:
echo "echo 12;" | powershell -noprofile -noninteractive -command { $input | iex }
Or use single quotes to avoid string interpolation:
echo "echo 12;" | powershell -noprofile -noninteractive -command '$input | iex'
therefore, the variable $ input will not be expanded, and the string '$ input' will be passed to iex.
Both of them give me "12".
source share