Passing Parameter to SQl Agent Job that runs powershell

  • Hi

    I have created a SQL Agent Job with a powershell step. The powershell script looks like the following:

    Param

    (

    [string]$A,

    [string]$B,

    [int]$C

    )

    #Do something with $A,$B and $C

    Now I have added it as a step and then created the job. What I am not able to figure out is how can I execute this job by passing parameters to the powershell script?

  • I use the Operating system (CmdExec) type to run Powershell scripts from jobs instead of the Powershell type. For parameters in that type just add them after the script name. Here's a command example from something that works for me.

    C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -Command E:\temp\someScript.ps1 param1 param2 33

  • This is the solution I am also following currently. Thanks a lot 🙂

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

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