6

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:

.\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?

5

Replace A-SVR with SRVR.

A-SVR is for alerts.

SRVR will contain server name and instance name.

Refer to document on MSDN.

  • Many thanks! That was the mistake... "D'oh!" :) – Homer Simpson Aug 17 '15 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.