Adicionando meus 2 centavos para isso, pois pode ajudar alguém ...
O código abaixo está faltando a parte "loop", onde eu li um csv para obter os arquivos para copiar
# first we setup an array of possible robocopy status
$RobocopyErrors="NO ERRORS",
"OKCOPY",
"XTRA",
"OKCOPY + XTRA",
"MISMATCHES",
"OKCOPY + MISMATCHES",
"MISMATCHES + XTRA",
"OKCOPY + MISMATCHES + XTRA",
"FAIL",
"OKCOPY + FAIL",
"FAIL + XTRA",
"OKCOPY + FAIL + XTRA",
"FAIL + MISMATCHES& goto end",
"OKCOPY + FAIL + MISMATCHES",
"FAIL + MISMATCHES + XTRA",
"OKCOPY + FAIL + MISMATCHES + XTRA",
"***FATAL ERROR***"
#setting some variables with the date
$DateLogFile=get-date -format "yyyyddMMhh"
#this commands below one usually goes into a loop
$DateLog=get-date -format "yyyyddMMhhmmss"
#adding options and command arg as described in previous post
$options = @("/R:0","/W:0")
$cmdArgs = @("$Source","$Destination",$File,$options)
#executing Robocopy command
robocopy @cmdArgs
# We capture the lastexitcode of the command and use to confirm if all was good or not
$errorlevel=$LASTEXITCODE
# I output the status to a log file
"$DateLog't::$($RobocopyErrors[$errorlevel])::'"$file'"'t'"$Source'" -> '"$Destination'"" | out-file "$scriptPath\Logs\$DateLogFile.log" -append
if ($errorlevel -lt 8) {
#error below 8 = all is good
}
else {
# something bad happened ..
}