Hmm seems like $lastexitcode is a builtin variable. Nice!
robocopy "\\serverA\shareA" "\\serverB\shareB" /MIR /R:0 /W:0 /MT:4 /NP /LOG:"d:\logs\shareA_to_shareB.log" | out-null interpret_robocopy_error $lastexitcode
and the function interpret_robocopy_error could be something quick’n'dirty like this:
function interpret_robocopy_error ([int]$errorlevel) { if ($errorlevel -eq 16) { echo " - Robocopy - ***SERIOUS FATAL ERROR*** "} if ($errorlevel -eq 15) { echo " - Robocopy - OKCOPY + FAIL + MISMATCHES + XTRA "} if ($errorlevel -eq 14) { echo " - Robocopy - FAIL + MISMATCHES + XTRA "} if ($errorlevel -eq 13) { echo " - Robocopy - OKCOPY + FAIL + MISMATCHES "} if ($errorlevel -eq 12) { echo " - Robocopy - FAIL + MISMATCHES "} if ($errorlevel -eq 11) { echo " - Robocopy - OKCOPY + FAIL + XTRA "} if ($errorlevel -eq 10) { echo " - Robocopy - FAIL + XTRA "} if ($errorlevel -eq 9) { echo " - Robocopy - OKCOPY + FAIL "} if ($errorlevel -eq 8) { echo " - Robocopy - FAIL "} if ($errorlevel -eq 7) { echo " - Robocopy - OKCOPY + MISMATCHES + XTRA "} if ($errorlevel -eq 6) { echo " - Robocopy - MISMATCHES + XTRA "} if ($errorlevel -eq 5) { echo " - Robocopy - OKCOPY + MISMATCHES "} if ($errorlevel -eq 4) { echo " - Robocopy - MISMATCHES "} if ($errorlevel -eq 3) { echo " - Robocopy - OKCOPY + XTRA "} if ($errorlevel -eq 2) { echo " - Robocopy - XTRA "} if ($errorlevel -eq 1) { echo " - Robocopy - OKCOPY "} if ($errorlevel -eq 0) { echo " - Robocopy - No Change "} }