title: How to properly get the variable name and import it to task schedular with powershell?
body: <p>I have some problem with this line of code. Currently I'm able to loop all the xml files name inside a folder. But the how to use that variable and put after C:\Windows\System32\Tasks\Job\? Currently the powershell always detect it as the text.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$fileDirectory = "C:\Windows\System32\Tasks\Job\*.xml";
  foreach($file in Get-ChildItem $fileDirectory)
  {
      $file.name
  Register-ScheduledTask -xml (Get-Content "C:\Windows\System32\Tasks\Job\$file.name" | Out-String) -TaskName $file.name -TaskPath "\Job" -User "MyAccount" –Force
  }
  </code></pre>