1

I am trying to run a PowerShell script via the command line via SQL Job.

"C:\Windows\System32\WindowsPowerShell\v1.0" "C:\Test\TestScript.ps1"

I am running the SQL Job from a SQL Server 2008 R2 server. Which permissions does the SQL Job Agent Service Account need to run a PowerShell script? Or is this a windows permission level, not a db permission?

EDIT: This is the error I am getting Executed as user: ****.

The process could not be created for step 3 of job ## (reason: Access is denied). The step failed.

enter image description here enter image description here

0

2 Answers 2

3

You have to call powershell.exe instead of the foldername

Change this

"C:\Windows\System32\WindowsPowerShell\v1.0" "C:\test\testscript.ps1"

To this

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "C:\test\testscript.ps1"

Testing by creating the same jobstep

enter image description here

The original command

"C:\Windows\System32\WindowsPowerShell\v1.0" "C:\test\testscript.ps1"

The error

Executed as user: ServiceAcc. The process could not be created for step 1 of job .. (reason: Access is denied). The step failed.

Changing the command and running the job again

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "C:\test\testscript.ps1"

Great success

enter image description here

1

The first thing I would check is that the SQL agent account has access to all of the drives/folders required for the operation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.