Find out what instance the job with powershell step is running on.

Hi,

We have multiple environments with different instance names.  Currently I use this command to define the connection to the instace:

SL SQLSERVER:\SQL\"MYDEV\MYINSTANCE"\Databases\"MyDB"\Tables

So the instance name is hard coded.  

I am running the script as a job step and need this job to work in all environments without updating the job code.

How do I find out the server and the instance name with powershell on which the SQL job is running?

 

Thanks.

 

 

 

Parents
No Data
Reply
  • To run a query you would need to provide the connection details, which change from environment to environment and which you are after.

    Is there a way to tell powershell to use the local sql server on which the job is running?

Children
No Data