SQL Server Jobs – syspolicy_purge_history fails

Posted on

Question :

The job syspolicy_purge_history fails at the 3rd step. The error that I get is the following one:

Executed as user: UserABC.
A job step received an error at line 1 in a PowerShell script.
The corresponding line is ‘set-executionpolicy RemoteSigned -scope process -Force’.
Correct the script and reschedule the job.
The error information returned by PowerShell is: ‘Security error. ‘. Process Exit Code -1. The step failed.

Was wondering if you guys have faced this before and how to go about fixing this.

Answer :

Thanks to the comment of @Tony Hinkle. I was able to resolve the issue based on the comment at the bottom of this thread.

SQL Server 2012 syspolicy_purge_history fails step 3 “Erase Phantom System Health Records.”

Under HKEY_LOCAL_MACHINESOFTWAREMicrosoftPowerShell1ShellIdsMicrosoft.SqlServer.Management.PowerShell.sqlps130 I changed the key ExecutionPolicy value to Unrestricted.

I did not make any changes to keys under HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftPowerShell1ShellIdsMicrosoft.SqlServer.Management.PowerShell.sqltoolsps130.

Leave a Reply

Your email address will not be published. Required fields are marked *