Solved

PowerShell SQL Job Failure

Posted on 2014-07-25
1
467 Views
Last Modified: 2014-08-13
I have a PowerShell job which is continuously failing when running it in SQL Server. The error message is not giving me any insight at all. It is just stating that the step is failing.

I have inherited this job from a previous owner and am not sure exactly what it is doing. Any help or suggestions would be appreciated here.

Script

if ('$(ESCAPE_SQUOTE(INST))' -eq 'MSSQLSERVER') {$a = '\DEFAULT'} ELSE {$a = ''};
(Get-Item SQLSERVER:\SQLPolicy\$(ESCAPE_NONE(SRVR))$a).EraseSystemHealthPhantomRecords()


Thanks In Advance
0
Comment
Question by:VitaminD
1 Comment
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 500 total points
Comment Utility
Hi VitaminD,
There is a MS Support article which refers to EraseSystemHealthPhantomRecords()
http://support.microsoft.com/kb/955726

and the line of script that you posted is similar to what is in one of the steps in the standard system job 'syspolicy_purge_history'

Another idea, you could put the job code in  a try...catch block to get more diagnostic information about the error, but be careful not to modify any system jobs and if making any modifications make good backups first.
 try
   {
   
    # DO SCRIPT STUFF HERE
   

   }
   catch [Exception]
   {
       
        # log errors to file
      $newline = $CurrentDateTime.ToString() + "|" + $_.Exception.Message
        Add-Content -Path "c:\ERRORS.log" -Value $newline
   
   }
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now