Not able to run powershell scripts from SQL Agent job

0

From past couple of days in one of our SQL servers syspolicy_purge_history jobs fails at third step executing a powershell script to clean Phantom Health records. The job is failing with the error:

Application popup error - SQLPS.exe The application was unable to start correctly (0xc0000142). Click OK to close the application. 

Edit: Identified that this happens only when calling this from SQL Agent job. When I manually load SQLPS to powershell and run the script it executes just fine. Also, even a simple Write-Host stmt as well fails to execute with the same message above which seems like a security issue to me. But I changed the job owner from sa to a domain account which have both sa and local admin rights on the box with no luck. Any ideas will be appreciated. Thank you!

sql
sql-server
powershell
sql-server-2012
powershell-3.0
asked on Stack Overflow Jan 20, 2017 by RMu • edited Jan 24, 2017 by RMu

2 Answers

1

So the issue is security related. I have admin rights on the box. I have created proxy account with my account and used proxy to run powershell scripts. It works without issues. Not sure what permission is missing for the agent account. Server admin is investigating what's changed. Once we found that I will update the answer here as well.

Update:

Reboot it is!! Whew! There aint anything wrong with the Agent account. Something with the agent account was broke! Glad the issue is resolved. The server was rebooted after the patch and there was no pending reboot. Also, after patching the job ran successfully 2 days. So just a weird failure! I'm unable to find what broke the account.

answered on Stack Overflow Jan 24, 2017 by RMu • edited Jan 27, 2017 by RMu
0

Had exactly the same issue as described, except it was for a custom job calling a Powershell script on the local file system. A restart of SQL Server Agent was all that was needed to fix the issue.

answered on Stack Overflow Jan 19, 2020 by nmbell

User contributions licensed under CC BY-SA 3.0