I am trying to run the following powershell script as a job from SQL server Agent (2008 R2), however, I
"Unable to start execution of step 2 (reason: The job step contains tokens. For SQL Server 2005 Service Pack 1 or later, you must use the appropriate ESCAPE_xxx macro to update job steps containing tokens before the job can run.). The step failed."
I run other jobs as Type "powershell" defined steps with variables which works fine, but I cannot get my head around which bit is the "Token". All help appreciated.
$source_dir = "B:\Database_Backups"
$target_dir = "\\machine-b\backup_Database_Backups"
foreach ($i in Get-ChildItem $source_dir)
if ($i.CreationTime -gt ($(Get-Date).AddDays(-2)))
Copy-Item $i.FullName $target_dir