I get error when calling Powershell script from SQL Server job
fine when ran interactively. when schedule dts sql sever job
fails following error:
executed user: mhpnt\mhpsqlservice. file j:\eventviewer\getsystemlog.ps1
cannot loaded because execution of scripts disabled on
system. please see "get-help about_signing" mor e details. @ line:1
char:2 + & <<<< 'j:\eventviewer\getsystemlog.ps1' + categoryinfo
: notspecified: (:) [], pssecurityexception + fullyqualifiederrorid :
runtimeexceptiondtsrun: loading... dtsrun: executing... dtsrun onstart:
dtsstep_dtsexecutesqltask_4 dtsrun onfinish: dtsstep_dtsexecutesqltask_4
dtsrun onstart: dtsstep_dtscreateprocesstask_1 dtsrun onerror:
dtsstep_dtscreateprocesstask_1, error = -2147220330 (80040496) error
string: createprocesstask 'dtstask_dtscreateprocesstask_1': process
returned code 1, not match specified successreturncode of 0.
error source: microsoft data transformation services (dts) package
file: sqldts80.hlp context: 4900 error detail records:
error: -2147220330 (80040496); provider error: 0 (0) error string:
createprocesstask 'dtstask_dtscreateprocesstask_1': process returned code
1, not match specified successreturncode of 0. error
source: microsoft data transformation services (dts) package file:
sqldts80.hlp context: 4900 dtsrun onfinish:
dtsstep_dtscreateprocesstask_1 dtsrun: package execution complete.
process exit code 1. step failed.
within dts, 1 of task "execute process task" executes:
powershell.exe -command "& { j:\eventviewer\getsystemlog.ps1}"
based on error, thought need add "set-executionpolicy
unrestricted" profile, added profile located
@ c:\windows\system32\windowspowershell\v1.0. didn't , still
error "....file j:\eventviewer\getsystemlog.ps1 cannot loaded
because execution of scripts disabled on system. please see
"get-help about_signing" mor e details." in job history.
checked execution policy using get-executionpolicy , returns
"unrestricted".
can me: why script fails when run sql server job ?
fyi, i'm running on windows server 2003 64-bit sp2 , sql server 2008
enterprise edition (64-bit) rtm.
in advance,
jimmy
i found out why failing:
when job running, runs in context of account starts sql server agent service. decided remote desktop server job located , run there -noexit check execution policy. when comes task runs powershell script, kicks off command-line window error mentioned. then, checked execution policy, "resctricted". so, while still in command-line window, changed execution policy "remotesigned" , exit it. after change, re-ran job management studio pc (instead of remote desktop server) , ran successfully.
Windows Server > Windows PowerShell
Comments
Post a Comment