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?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

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

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