I have a SQL 2008 job that does database backups using a Powershell script. Each step in the SQL job is "Operating system (CmdExec)" type. Each step kicks off a powershell script that performs SQL backup and other things. That script lives on a remote server, so that if we need to make changes, we only have to make them once.
If I set the Powershell execution policy to "Bypass", the SQL job works. But if I set it to "remote signed", it fails saying that the execution policy is not set correctly. However, If I kick off the script from the CMD window, it runs correctly. The server is 64 bit, so I have made sure that both the 32 bit and 64 bit shells have their execution policy set to "remotesigned". And, I have the remote server UNC path set as a trusted intranet site in IE (found that Powershell treats local UNC paths like http paths, unless that is set in IE).
Like I said, it runs correctly I manually kick if off from the CMD window with the execution policy set to remote signed, and it works if the SQL job kicks if off if the execution policy is set to bypass. It only fails if it gets kicked off from SQL and the execution policy is set to remotesigned.
It’s been running for a year without an issue with the Powershell execution policy set to bypass, but I’m being told to set that execution policy to remotesigned now. Keeping it at bypass is no longer an option.
Any thoughts?
Sounds like the credentials under which the job is run is different from your login credentials.
You may have to change the permissions for the agent job user to allow the powershell script to run as expected.