SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


powershell script through agent job only performing half the steps it should.


powershell script through agent job only performing half the steps it should.

Author
Message
Jeff Shurak
Jeff Shurak
SSC-Enthusiastic
SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)

Group: General Forum Members
Points: 195 Visits: 763
Ok. I'm out of ideas.
I have a script that grabs a list of sqlserver instances, then connects to each (foreach), executes a query and loads the results into a table.
Every time I execute the script through a sql agent job(via cmdexec) , it only queries against 2 of the 4 servers it should.
Its run successfully from powershell, powershell ise, starting powershell through sql server, it even runs successfully if I run it through a standard command prompt.
Any ideas?
bruce 1565
bruce 1565
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 1018
Any errors or does it just exit? Are you doing any logging that might help point to the issue?
I do something similar but have one server that would throw a connection error. I had to monkey the connection string for it before my script would run to completion.
Leonard Rutkowski
Leonard Rutkowski
SSC Veteran
SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)

Group: General Forum Members
Points: 272 Visits: 1213
I do something similiar, with a couple of differences. One, I run the step as type PowerShell. The other thing I do, and I suspect this may be your problem, I have a proxy login, that has access to the other servers. Then I change the Run as option to the proxy. Otherwise, the SQL job will run, using the SQL Server agent service account. I do use Windows Authentication, so if you are using SQL login, in your Powershell script, then you should be ok. Since you said you are using cmdexec, i assume you are running a bat file, or executing the powershell exe?

Leonard
Jeff Shurak
Jeff Shurak
SSC-Enthusiastic
SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)SSC-Enthusiastic (195 reputation)

Group: General Forum Members
Points: 195 Visits: 763
So this system is a vast modular monitoring system. The odd thing is that many of the other modules work totally fine. I added some logging to this particular module. Its so odd. The query being executed returns 0 results when run through sql agent. Only for this module.

Eh, I gave up. I scheduled it using windows scheduler and its working fine.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search