0
votes

I created a SQL Server Agent job and here is the job detail.

  • The job owner is my windows domain login.
  • The type is OS (cmdExec)
  • Run as SQL Server Agent Service Account
  • Command:

    powershell.exe -executionpolicy bypass -file "D:\MyFolder\myFile.ps1".

When I ran the job it returned an error stating "D:\MyFolder\myFile.ps1" does not exist.

When I run the same command from cmd prompt it works find.

My question is what can I do to make SQL Server Agent Service Account "see" the file?

Thanks,

1
what's D:? a physical local drive, or a network drive? - Marc B
@shawn you can also try and create a basic task in Task Scheduler to see if its related to SQL Agent process executing it. Would also try changing the path to the System OS Drive somewhere for testing purposes. - ATek
D is a local drive. Task scheduler works fine. Somehow the SQL Agent couldn't spot the file. - Shawn

1 Answers

0
votes

It's a privilege issue. I just granted read/execute permission to the Network Service login which SQL Server Agent uses.

It works now.

And thanks for all your responses.