I was debugging a program that uses Windows API (Creating a Child Process with Redirected Input and Output) to capture stdout of Microsoft’s Windows PowerShell.
Script passed to PowerShell (-File switch) didn’t execute and PowerShell just hanged until killed by Task Manager.
It turns out that you need to use undocumented parameter “-InputFormat none”:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -InputFormat none -File file.ps1
This is discussed in MS Connect site: PowerShell.exe can hang if STDIN is redirected.
Similar issue at StackOverflow: Silently executing a PowerShell script from WiX Hangs PowerShell.