Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Get output from robocopy before logfile is written

$
0
0

I have a PowerShell script that executes robocopy like this:

robocopy "D:\source_folder" "\\adrive\destination_folder"  /S /r:2 /w:4 /LOG:$Logfile

It works when the network is up, but when the network is down the log file says:

2016/04/11 14:52:27 ERROR 53 (0x00000035) Accessing Destination Directory \\adrive\destination_folder

The network path was not found.

Waiting 4 seconds... Retrying...

What I want is to get access to the output from robocopy before it writes to a file and test for ERROR 53 and then send myself an email right away, not when the script fails. The way the script works now, it checks the value of $LASTEXITCODE. However, that is unnecessary if robocopy can't find the directory. As well, I'm concerned that by setting the wait time to 4 seconds, it might time out before it finds the network anyway.

Is it possible to get the output of robocopy before writing to the log file?

Thanks


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>