I made a function that must return a job running robocopy in power shell but there is an issue with the log parameter:
This works :
function RunRobocopyJob { param ([object]$pSynchronization)
$logPath = $pSynchronization.logPath
return Start-Job -ScriptBlock { robocopy $using:pSynchronization.source $using:pSynchronization.destination /MIR /PURGE /LOG:$using:logPath }
}
But this does not :
function RunRobocopyJob { param ([object]$pSynchronization)
return Start-Job -ScriptBlock { robocopy $using:pSynchronization.source $using:pSynchronization.destination /MIR /PURGE /LOG:$using:pSynchronization.logPath }
}
I can tell that something is missing in the second case because Powershell ISE "logPath" property is colored violet insted of black, with means it is not interpreted as an object property like the others. I thinck that's because it is next to "/LOG:"
So my question is : what is the correct syntax to make it work ?