Fails when executing job called syspolicy_purge_history (SQL Server 2012)

Hi friends i have the following  problem

The job syspolicy_purge_history  of my database engine failed, specifically on the third step called "Erase Phantom System Health Records" that executes a powershell.  This is the sentence that executes (All job syspolicy_purge_history on any SQL 2012 has the same code):

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

.  When i see the job history i get the following:

Message
Executed as user: NT Service\SQLSERVERAGENT. The job script encountered the following errors. These errors did not stop the script:  A job step received an error at line 1 in a PowerShell script. The corresponding line is 'import-module SQLPS  -DisableNameChecking'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory.  '  A job step received an error at line 2 in a PowerShell script. The corresponding line is '(Get-Item SQLSERVER:\SQLPolicy\SRV01236$a).EraseSystemHealthPhantomRecords()'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Cannot find drive. A drive with the name 'SQLSERVER' does not exist.  '  A job step received an error at line 2 in a PowerShell script. The corresponding line is '(Get-Item SQLSERVER:\SQLPolicy\SRV01236$a).EraseSystemHealthPhantomRecords()'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'You cannot call a method on a null-valued expression.  '.  Process Exit Code -1.  The step failed.

Aditionally i tested putting the policies in powershell like unrestricted (like i see on a blog). but it didn't work.

My SQL version is 2012 Standard SP1 X64

Please help me with this

Thanks for your help

Greetings

Aleds



  • Edited by Aleds 19 hours 47 minutes ago
February 18th, 2015 10:40am

hi,

you need SQL Server 2012 for module to load

http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/6901b420-c6f6-401f-ab8e-568f4d646cd5/

Free Windows Admin Tool Kit Click here and download it now
February 19th, 2015 12:35am

looks like incorrectly loaded SQLPS ( didn't see SQLPS module in Get-Module -ListAvailable). Please run the repair utility in SQL install.

February 19th, 2015 12:53am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics