0
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!!
1What troubles are you facing? Please include any relevant errors – Smeerpijp – 2020-02-11T10:13:17.590
I actually am not seeing any error, it's just not copying the new directory. – Alexander Espiritu – 2020-02-11T22:13:20.017
You're missing quotes on the file path, which has a whitespace. Have you considered simply using
%ProgramFiles%\SplunkUniversalForwarder\etc\apps
(if using within a PowerShell terminal or script, command must be prefaced withcmd /c
, as PowerShell does not recognize%
variables, just as Command Prompt terminals don't recognize$
variables). – JW0914 – 2020-02-16T13:20:34.957