Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Failed SQL job info from PS to sql table Expand / Collapse
Author
Message
Posted Wednesday, July 11, 2012 12:02 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, May 10, 2013 5:51 PM
Points: 54, Visits: 121
Hi All,

Please have a look at the below link and help me to get the details (as 4 Columns) into a SQL Server table instead of Mail as I can make a SSR report from the data.
SERVER =
JOB =
LASTRUN =
LASTRUNDATE =

http://www.sqlservercentral.com/blogs/sqlsandwiches/2012/01/29/find-failed-sql-jobs-with-powershell/

Regards
Srikanth Reddy Kundur
Post #1328482
Posted Wednesday, July 11, 2012 12:16 PM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 30, 2013 12:43 PM
Points: 46, Visits: 722
Have you tried to change the part where it says
$msg.body = $msg.body + "`n `n FAILED JOB INFO:... [snip]
to something like this
$sql = "insert YourTableName (server, job, last_run_status, last_run_date)
values ('$sqlserver', '$jobname', '$jobLastRunOutcome', '$jobLastRun');"

then run that into your SQL Server? Adjusted, of course, for your table structure.
If you have something that's failing send the code and error message and maybe someone here could help a little more.
Post #1328487
Posted Wednesday, July 25, 2012 6:09 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, May 10, 2013 5:51 PM
Points: 54, Visits: 121
Changed the code as suggested, the job executes successful but no records are getting inserted, Can anyone help on the script please.

Regards
S.R.Kundur
Post #1335514
Posted Tuesday, January 08, 2013 11:39 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 11:25 PM
Points: 946, Visits: 1,739
Paste your complete PS code here. Also, is there a specific reason not to use sysjobshistory and sysjobs tables for reporting needs?

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
Post #1404557
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse