M BUZZ CRAZE NEWS
// news

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 /mir

But 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!!

3

1 Answer

Try this:

psexec.exe \\$computer -c "robocopy $splunkconfig 'C:\Program Files\SplunkUniversalForwarder\etc\apps' /is /it /copyall /mir"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy