Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PowerShell SQL Job Failure

Posted on 2014-07-25
1
Medium Priority
?
578 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 2000 total points
ID: 40219480
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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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.

704 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