syspolicy_purge_history sql job failed
错误信息如下:
'File C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\SQLPS\Sqlps.ps1 cannot be loaded because running scripts is disabled on this system
根据错误信息提示检查发现服务器注册表里缺少内容-Microsoft.SqlServer.Management.PowerShell.sqlps130键值对信息
应该是这样的,
更新注册表即可。把下面代码块里的内容粘贴到文本编辑器里,修改后缀为.reg,然后鼠标左键双击执行。
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps130] "Path"="C:\\Program Files (x86)\\Microsoft SQL Server\\130\\Tools\\Binn\\SQLPS.exe" "ExecutionPolicy"="RemoteSigned"
参考文档 https://blog.pythian.com/powershell-error-sqlps-ps1-cannot-loaded-running-scripts-disabled-system/