Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

Problem with Powershell and SQL Agent Job token

$
0
0
I'm working on a script that will transfer SQL Agent Jobs to another job server. One of the jobs uses the SQL Agent Token in a step:[code="sql"]WHERE job_id = $(ESCAPE_SQUOTE(JOBID)) [/code]Once the job is scripted out to a variable, I need to do -replace a string value with another string value to prepare the job script for the new environment. The values I want to replace are not even in this part of the script, but it causes Invoke-SQLCmd to fail because Powershell attempts to interpret the $() as an expression.Any suggestions?

Viewing all articles
Browse latest Browse all 467