SQL Server Jobs - syspolicy_purge_history fails 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.
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_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps130 I changed the key ExecutionPolicy value to Unrestricted.

I did not make any changes to keys under HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqltoolsps130.