Calling remote powershell script through SQL server agent

  • I have a powershell script in remote server.  When I go to remote server and execute the script, it works as indented.

    When I schedule it to run through SQL server agent, it just says succeeded but code really doesn't do anything.

    Any help would be appreciated.

    I've attached sql server agent image, how the job is setup.

     

    Am I missing something?

     

     

     

    Attachments:
    You must be logged in to view attached files.
  • Are you hoping that the script will execute on the remote server? Or is that just the place where you store PoSh scripts?

    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

  • Yeah, hoping that the script will execute on the remote server.

  • SQL_Surfer wrote:

    Yeah, hoping that the script will execute on the remote server.

    Unfortunately, it won't. It will instead try to execute locally.

    But all is not lost, you can use Powershell Remoting to execute PoSh commands on remote servers. Take a look here to get started:

    https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.1

    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

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

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