title: PowerShell, Robocopy and SchTasks --> Send variables and text for the command
body: <p>I have a little problem with my Powershell backupscript.
  I use the Task Scheduler with Robocopy to deploy my backups. </p>
  
  <p>This is an example of a command:</p>
  
  <pre><code>schtasks /Create /SC ONCE /TN $TaskName /TR "robocopy.exe $Source $Target /E /COPY:DAT /V /R:0 /W:0 /LOG+:$LogPfad" /ST $StartTime /SD $StartDate /F
  </code></pre>
  
  <p>The problem is, that when I run my script, the task will appear, but it uses the same text with the same variables</p>
  
  <p>For example, this script will run the task with this command:</p>
  
  <pre><code>robocopy.exe $Source $Target /E /COPY:DAT /V /R:0 /W:0 /LOG+:$LogPfad
  </code></pre>
  
  <p>So that the Backup can't run properly.</p>
  
  <p>It should be saved in the task like this:</p>
  
  <pre><code>robocopy.exe C:\test\source D:\test\target /E /COPY:DAT /V /R:0 /W:0 /LOG+:$LogPfad
  </code></pre>
  
  <p>There is an option, that I could save the command in a .bat file and execute it, but this shouldn't be the solution.</p>
  
  <p>Would be fantastic, if somebody could help me! :D</p>
  
  <p>Best regards</p>
  
  <p>lucbas</p>