Use PsExec to run robocopy
By Mia Morrison •
Hi I'm currently making a script that copies a directory to another. I'm currently using this:
robocopy $splunkconfig 'C:\Program Files\SplunkUniversalForwarder\etc\apps' /is /it /copyall /mirBut when I tried to combine it with psexec I'm having trouble making it work. Here's what I've tried so far:
Start-Process -FilePath $PSExecExePath -ArgumentList @("\\$computer -e -s cmd.exe /c", "robocopy $splunkconfig \\$computer\c$\Program Files\SplunkUniversalForwarder\etc\apps /is /it /copyall /mir")and
Start-Process -FilePath $PSExecExePath -ArgumentList @("\\$computer -e -s cmd.exe /c", "`"robocopy $splunkconfig \\$computer\c$\Program Files\SplunkUniversalForwarder\etc\apps /is /it /copyall /mir`"")Any help would be great. thank you!!
31 Answer
Try this:
psexec.exe \\$computer -c "robocopy $splunkconfig 'C:\Program Files\SplunkUniversalForwarder\etc\apps' /is /it /copyall /mir"