Powershell passing in arguments along with Standard Input

view story

http://serverfault.com – I am trying to start a PowerShell script where the script is written to PowerShell.exe via standard input, for example: echo Write-Host hello | powershell.exe -Command - -Command - instructs powershell to use the standard input as the source of the script to execute. That all works fine. Now what I want to do is specify variables as well, in conjunction with using Standard Input, but I can't seem to get this to work. Something like this: echo Write-Host $foo | powershell.exe -foo bar -Command - That doesn't work, however. How can I use arguments like this when I am using a script from (HowTos)