November 9, 2016 at 12:37 pm
Hi guys,
Is it possible to set variable values when calling a SQL Agent Job from PowerShell? If we can, can somebody please direct me to some documentation?
Thanks is advance 🙂
November 10, 2016 at 3:01 am
I don't think so. I really don't think it even makes sense.
(If nothing else this mak encourage someone to correct me.)
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
November 10, 2016 at 5:42 am
Can you tell me why it doesn't make sense? That was not my question and it is certainly not my call here... just started working with the team!
So you're telling me that I can't call a SQL Agent job via .bat or .ps1 with new Property Path values ?
Thank you for the answer and sorry for the dum question...
November 10, 2016 at 1:19 pm
As far as I know, there isn't any way to do this. There are some job variables, within the SQL job that can be used, but probably not what your looking for, and you couldn't use them in a Powershell script, if that is what the job step is executing.
I had the same kind of issue, I wanted to execute a Powershell script, in a job step, and pass it the instance name. Couldn't find a way to do that, so just ended up using 'local' as the name, so it would connect to the SQL Server instance that was executing the job.
Passing the parameters, through the SQL job, you would need to have something to pass the parameters to the proper step.
As for your issue, you may need to have the Powershell script insert\update a table, then have your job step reference the table. Doing it that way, you can use any 'Type' (Powershell, T-SQL) access the table.
Leonard
November 10, 2016 at 1:22 pm
That's what I did. Thanks for the answer 🙂
November 11, 2016 at 1:15 am
mylenechalut (11/10/2016)
Can you tell me why it doesn't make sense? That was not my question and it is certainly not my call here... just started working with the team!So you're telling me that I can't call a SQL Agent job via .bat or .ps1 with new Property Path values ?
Thank you for the answer and sorry for the dum question...
No such thing as a dum question.
I believe that it is a requirement beyond the initial remit of SQL Agent jobs. And become the scope of running it via PowerShell.
Glad you have an answer.
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply