Jump to content
Brant

Passing Automate script parameter through to Powershell script

Recommended Posts

I'm looking for some feedback on if what I'm trying to accomplish is even possible at this point. I have an Automate script that is running a PowerShell script. I want the Automate script to pass an input parameter provided at runtime into the PowerShell script which, in turn, uses that input as a parameter on a PowerShell cmdlet inside the PowerShell script. I know that the PowerShell script as written works to do what I want it to do but I'm trying to make it so that the PS script doesn't have to be manually modified every time it needs to be run. And if this isn't obvious not a strong Automate scripter here so I could be all jacked up and not even know it. What the script is doing is creating a scheduled task inside Windows. The parameter I'm trying to pass is to designate the -At parameter to the New-ScheduledTaskTrigger cmdlet.

All the normal stuff is in place.

Function: Execute Script

Script Type: Powershell Bypass

Script to Execute: contains text of PS script

Script Parameters: Blank. But this has been tried with various iterations like @timetorun@ and %timetorun%. (TimetoRun being the parameter I have defined on the Automate script.)

Script Credentials: Run as Admin

Variable: Blank.

1. Is what I'm trying to do possible? If so, how do I set up the Automate script as well as what modifications, if any, are needed inside the PowerShell script?

2. Is this documented somewhere in docs.connectwise.com? The documentation I found didn't really go into what I'm specifically trying to do and so I'm thinking my use case may be unique.

 

Share this post


Link to post
Share on other sites

I believe the parameter is case sensitive, but may be wrong.  I've always used the same case.

Try a simple Script Log Message function to log @TimetoRun@ to ensure it's being set properly.

When I created a scheduled task I just used schtasks.exe so no PowerShell.

Share this post


Link to post
Share on other sites

Thanks Steve. I actually did that part and I can see the parameter from the Automate side is populating correctly with the value provided at run time. And I think there is a really good chance I'm over-engineering this too. I've got another "solution" to try but overall I would still be interested in knowing if you can pass the Automate parameter through to the PS script so that it is used inside that invocation (for future purposes of course.)

 

If this is doable (passing the parameter through) I'd love to see how others are doing it successfully.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...