Powershell error where external commands silently fail

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.

+3
source share
3 answers

, , , ; , write-host, , powershell V2 . , , , , powershell. powershell .

+1

, - , -, - script:

Write-Host **************************************

, , ... , . , ... , ? , ...:)

0

If you use the / R option with the robocopy command, try increasing the number of attempts. It is better to use the default value. Hope this works great.

-Archit

0
source

All Articles