Run Remote Powershell Script as a SQL server Job

  • I have a Power shell script that runs on computer1 and my sql server is on computer2
     I created a Powershell Proxy
    Then I create SQL Agent Job, with Step
    powershell.exe  -file "\computer1\c$\PowershellScript.ps1"
    When I run the Job I get error
         The error information returned by PowerShell is:  "\computer1\c$\PowershellScript.ps1" is  not digitally signed.
         The script will   not execute on the system. For more information, see about_Execution_Policies   at http://go.microsoft.com/fwlink/?LinkID=135170.      + CategoryInfo          : SecurityError: (:) [],    
          ParentContainsErrorRecord    
          Exception      + FullyQualifiedErrorId : UnauthorizedAccess    '.  Process Exit Code 0.  The step succeeded.
    How do I run this job sucessfully without getting error. What changes do I need to implement?
    There is Windows task scheduler that runs on the Computer1 and runs it successfully and it has same command, I want to convert this to SQL job instead of windows task

  • mandavli - Wednesday, April 26, 2017 8:26 AM

    I have a Power shell script that runs on computer1 and my sql server is on computer2
     I created a Powershell Proxy
    Then I create SQL Agent Job, with Step
    powershell.exe  -file "\computer1\c$\PowershellScript.ps1"
    When I run the Job I get error
    The error information returned by PowerShell is:  "\computer1\c$\PowershellScript.ps1" is  not digitally signed.
    The script will   not execute on the system. For more information, see about_Execution_Policies   at http://go.microsoft.com/fwlink/?LinkID=135170.      + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecord    
     Exception      + FullyQualifiedErrorId : UnauthorizedAccess    '.  Process Exit Code 0.  The step succeeded.

    Seems like a reasonable error message. What is your question?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Phil Parkin - Wednesday, April 26, 2017 8:48 AM

    mandavli - Wednesday, April 26, 2017 8:26 AM

    I have a Power shell script that runs on computer1 and my sql server is on computer2
     I created a Powershell Proxy
    Then I create SQL Agent Job, with Step
    powershell.exe  -file "\computer1\c$\PowershellScript.ps1"
    When I run the Job I get error
    The error information returned by PowerShell is:  "\computer1\c$\PowershellScript.ps1" is  not digitally signed.
    The script will   not execute on the system. For more information, see about_Execution_Policies   at http://go.microsoft.com/fwlink/?LinkID=135170.      + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecord    
     Exception      + FullyQualifiedErrorId : UnauthorizedAccess    '.  Process Exit Code 0.  The step succeeded.

    Seems like a reasonable error message. What is your question?

    I want to know, How do I not get that error , how can I correct the script so the job runs successfulkly?

  • Looks like the execution policy at the remote computer is too restrictive for your script to be run.  Did you follow the link given in the error message?

    John

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply