Home Forums Programming Powershell Failed SQL job info from PS to sql table RE: Failed SQL job info from PS to sql table

  • 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.