scheduling powershell tasks with sql agent

SVA 121 Reputation points
2022-08-24T19:42:28.047+00:00

Hi
How to run a powershell script through SQL Server agent.

SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. Tom Phillips 17,781 Reputation points
    2022-08-24T19:52:48.89+00:00
    1 person found this answer helpful.
    0 comments No comments

  2. PandaPan-MSFT 1,931 Reputation points
    2022-08-25T01:54:28.857+00:00

    Hi,@SVA

    I’m agree with what @Tom Phillips has already put before. His answer was perfect seems to me.

    You just need to follow the steps below:

    1.Expand SQL Server Agent, create a new job or right-click an existing job, and then select Properties.
    2.In the Job Properties dialog, select the Steps page, and then select New.
    3.In the New Job Step dialog, type a job Step name.
    4.In the Type list, select PowerShell.
    5.In the Run as list, select the proxy account with the credentials that the job will use.
    6.In the Command box, enter the PowerShell script syntax that will be executed for the job step. Alternately, select Open and select a file containing the script syntax.
    7.Select the Advanced page to set the following job step options: what action to take if the job step succeeds or fails, how many times SQL Server Agent should try to execute the job step,
    and how often retry attempts should be made

    Best regards


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.