patternshellMinor
Passing current server name from SQL Server Agent job to PowerShell
Viewed 0 times
sqlpassingpowershellagentnamecurrentserverfromjob
Problem
I have a SQL Server Agent job that calls a PowerShell script in one step. And I want to pass the SQL server name and the current job-id to my script.
With the job-id I have no problems. But with the server name...
My PowerShell call looks like this:
The job-id works perfect, but the server name is empty.
How can I pass the server name to my PowerShell script?
With the job-id I have no problems. But with the server name...
My PowerShell call looks like this:
.\StopServices.ps1 -ServerName $(ESCAPE_DQUOTE(A-SVR)) -JobId $(ESCAPE_DQUOTE(JOBID))The job-id works perfect, but the server name is empty.
How can I pass the server name to my PowerShell script?
Solution
Replace
Refer to document on MSDN.
A-SVR with SRVR.A-SVR is for alerts.SRVR will contain server name and instance name.Refer to document on MSDN.
Context
StackExchange Database Administrators Q#110907, answer score: 5
Revisions (0)
No revisions yet.