powershellscheduled-taskspowershell-2.0robocopygmsa

Robocopy, ScheduledTask and gMSA


Using a powershell script with robocopy launch by gMSA is not working ...

I write a little script to copy 2 directories in powershell with robocopy and it works. I use it with the task sheduler, with a normal account, it works. But doing the same with a gMSA, does'nt work

$logfile = "C:\Scripts\SyncFTP\Logs\SRV-IIS-1.txt"
$options = @("/E","/ZB","/X","/COPYALL","/XO","/FFT",("/LOG:" + $logfile))
$args = @("$pathFTP2","$pathFTP1",$options)
robocopy @args

Here is the log file of Robocopy when it is launch with gMSA :

ERROR : Invalid Parameter #10 : "C:\Scripts\SyncFTP\Logs\SRV-IIS-1.txt"

It is like the $logfile was not correct only when it is launched by gMSA...

Have you got some ideas ?


Solution

  • In my case, i do it like this :

    Invoke-Expression "& robocopy $pathFTP2 $pathFTP1 /E /X /COPY:DATSO /XO /FFT /LOG:$logfile"
    

    It seems to work now , before the WE ^^