Anyone else have problems when running a PowerShell script, where the script just hangs in one spot until you hit Enter or something on the console window? This happens to me all the time, and for the life of me I cannot figure out why.
Asked
Active
Viewed 1,860 times
1
-
2Check if your script has breaks, and read up on the cmdlets you're using and see if they have "force" options. If you can, try to edit your question to be more specific. I'm not sure it meets SF's quality standards as it is now. – Colyn1337 Apr 24 '15 at 17:26
-
1@Colyn1337 +1 - Unless you have a concrete example of a script that causes your powershell session to "hang", this is not really SF Q&A material – Mathias R. Jessen Apr 24 '15 at 17:32
-
Yup, definitely a duplicate. – GregL Apr 24 '15 at 18:02
1 Answers
0
I've seen this happen all the time to my sessions.
I often find it's because I've selected some text in the console, sometimes by accident, and it causes the PS console window to stop outputting text.
You can tell if this is the case by the window's title; it will be something like Select Windows PowerShell
instead of just Windows PowerShell
.
Paused:
Not paused:
GregL
- 9,030
- 2
- 24
- 35
-
This is usually more of a buffering issue when looking on the console. If you output to a file you shouldn't run into the issue. If you hit enter a few times, the output starts dumping. Infinite loops will eventually crash. – Colyn1337 Apr 24 '15 at 17:48
-
Nope, just confirmed by running`1..10 | %{random; sleep 2} >> output.txt`. Even after 60 seconds, the script still appears to be hung even though the task has completed (verified by seeing if 10 random numbers exist in `output.txt`). – GregL Apr 24 '15 at 17:51
-
Right, but hitting `enter` causes the selection to disappear and returns the window to its "normal" state. – GregL Apr 24 '15 at 17:53
-