Zend certified PHP/Magento developer

PowerShell hangs when closing with “X” button only when read-host is awaiting input

In Windows 10 Version 1809 build 17763.914 (LTSC 2019) with the latest updates installed, I’ve encountered an interesting issue with PowerShell that I did NOT have in Windows 10 Version 1607 Build 14393.2879 (LTSB 2016).

If I open up command prompt and enter the command:

powershell.exe -noexit "& cd 'C:UsersJohnDownloads'; Read-Host 'Press enter to exit'"

And I don’t press any key to exit, but instead press the red x enter image description herein the corner of the window, the window hangs for about five seconds before closing. If I remove the read-host command, it closes instantly when I press the x (as I would expect). If I press any key to exit, it also closes instantly. If I open up powershell directly (instead of from cmd), and then click the x while a read-host is awaiting a response, it closes immediately.

So the problem seems to exist specifically when running powershell from cmd and the red x is pressed while the read-host is expecting input.

I typically run many scripts like this, using read-host at the end to prevent the window from closing automatically, so naturally this is quite annoying. I’m not sure what about this specific build of Windows would be causing this oddly specific problem.

Does anybody have any idea how to fix this or what’s causing it? I have no choice but to use this specific build of Windows 10. As I mentioned earlier, the problem does not exist in Version 1607.