Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

how to run a SQL job script as admin?

$
0
0

Hi All,

im fighting with a script that automates backup and restore of a DB (from remote SQL to local SQL)

the script should run from within the SQL server as an Agent Job.

what i have done so far:

  1. Created a dedicated domain account for the SQL Agent.
  2. configured the agent service to run with the mentioned account
  3. granted him local admin membership, SQL admin membership and login as a service permission
  4. created a Job with a single step of type: CmdExec that runs the following command:

Batchfile
c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -command ". 'C:\Scripts\Refresh\Refresh_SQL.ps1' -Verb runAs"

the script itself starts fine and performs a backup of a db but it keeps failing on a move-item command that should transfer the bak file from remote sql to the local sql:

Powershell
...

Viewing all articles
Browse latest Browse all 4871

Trending Articles