Simple PowerShell script that harms PS console

This question is related in the spirit of Powershell Command Prompt prints ^ C when Ctrl + C is pressed, why? - both deal with a PowerShell console that is screwed on.

Given:

  • Windows 10 or 8 or 8.1
  • PowerShell Console

Consider the following script:

$iisexpress = "C:\Program Files (x86)\IIS Express\iisexpress.exe"
$config = "c:\xyz\.vs\config\applicationhost.config"
$logFile = "$env:temp\1.log"
$id = (Start-Process $iisexpress "/site:Site1","/config:$config" -PassThru -RedirectStandardOutput $logFile -NoNewWindow).Id
$id

      

I don't think the specific configuration of the solution is important here. The important thing is that I start the site by redirecting the exit and collecting the process id.

What is it. Try a little console work. If nothing happens, run the script again, although this is not necessary. The console is damaged.

Why? How to fix it?

+3


source to share


1 answer


I believe the flag -NoNewWindow

is causing you problems. iisexpress.exe is launched from a Powershell window with this switch and seems to partially hijack your input.



I'm still curious to know why this is happening and there is no answer yet, but an easy fix is ​​to replace -NoNewWindow

with-WindowStyle hidden

+6


source







All Articles