Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Passing Parameter to SQl Agent Job that runs powershell Expand / Collapse
Author
Message
Posted Saturday, June 28, 2014 6:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 17, 2014 5:00 AM
Points: 4, Visits: 8
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?
Post #1587137
Posted Saturday, June 28, 2014 8:51 AM This worked for the OP Answer marked as solution


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:30 PM
Points: 60, Visits: 892
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

Post #1587161
Posted Thursday, July 3, 2014 5:32 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 17, 2014 5:00 AM
Points: 4, Visits: 8
This is the solution I am also following currently. Thanks a lot :)
Post #1588808
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse