I have a complex powershell script that uses remoting and does a lot of file copying and loading and unloading of powershell modules. Within the script I use robocopy to move only changes files and anything works OK.
However, every now and then the powershell session gets into a weird state whereby it no longer executes external commands. For instance if I type robocopy into the console it just returns immediately with no error and no output. If I type whoami, it again returns immediately with no output. It only gets into this state about 1 in 10 executions of the same script.
If I close the console and start a new session everything goes back to normal. Any idea what's going in here? I can't figure out a way to debug or fix this state.
Thanks, Mike
Update It looks like there's a known issue with passing arrays to write-host that can cause this behavior. I don't believe I'm doing this, but it's difficult to know for sure. I've managed to put a trap in place testing when the result of whoami becomes empty. Oddly it appears to happen whilst waiting for a long running remote operation.