I have a complex powershell script that uses remote access and copies files a lot, and also loads and unloads powershell modules. In the script, I use robocopy to move only change files, and everything works fine.
However, from time to time, a powershell session goes into a strange state in which it no longer runs external commands. For example, if I enter robocopy into the console, it immediately returns without errors and without output. If I type whoami, it returns again immediately without output. It only gets into this state in about 1 out of 10 executions of the same script.
If I close the console and start a new session, everything will return to normal. Any idea what is going on here? I cannot find a way to debug or fix this condition.
Thanks Mike
Update
There seems to be a known issue with passing arrays to a host entry that might cause this behavior. I do not believe that I am doing this, but it is difficult to understand for sure. I managed to check the trap in place when the whoami result becomes empty. Oddly enough, this happens, waiting for a long remote operation.
source
share