powershell - Poweshell script is executing but not working -
i have powershell script running fine in windows power shell ide. when running sql agent job running no error isn't doing operation. below message getting in job history
executed user: server\system. string starting: @ line:1 char:1 + <<<< "d:\folder\powerscript.ps1? missing terminator: ". @ line:1 char:23 + "d:\folder\powerscript.ps1? <<<< + categoryinfo : parsererror: (d:\folder\powerscript.ps1?:string) [], parentcontainserrorrecordexception + fullyqualifiederrorid : terminatorexpectedatendofstring. process exit code 0. step succeeded.
though, have ran service account "domain\serviceaccount" showing me "servername**system**
let me know if more details required.
edit- script of job
declare @jobid binary(16) exec @returncode = msdb.dbo.sp_add_job @job_name=n'myjob', @enabled=1, @notify_level_eventlog=0, @notify_level_email=0, @notify_level_netsend=0, @notify_level_page=0, @delete_level=0, @description=n'no description available.', @category_name=n'[uncategorized (local)]', @owner_login_name=n'domain\serviceaaccount', @job_id = @jobid output if (@@error <> 0 or @returncode <> 0) goto quitwithrollback /****** object: step [run monitor] script date: 5/15/2015 11:01:29 ******/ exec @returncode = msdb.dbo.sp_add_jobstep @job_id=@jobid, @step_name=n'run monitor', @step_id=1, @cmdexec_success_code=0, @on_success_action=1, @on_success_step_id=0, @on_fail_action=2, @on_fail_step_id=0, @retry_attempts=0, @retry_interval=0, @os_run_priority=0, @subsystem=n'cmdexec', @command=n'powershell “d:\folder\powerscript.ps1″', @flags=0
@command=n'powershell “d:\folder\powerscript.ps1″',
the quote marks here don't right. should remove them , re-type them double-quote marks, this:
@command=n'powershell "d:\folder\powerscript.ps1"',
can see difference? occurs when copying , pasting values.
Comments
Post a Comment