Schulded Jobs with Paramerters

Do we have a way to schedule jobs with pre-set script parameters? I have one script that I need to run against several different sets of parameters on a Timmer. I would like to not have to have several copies of the same script in UA but that is an ok work around for now.

Not at the moment but I’ll add it to our backlog! You should be able to do this.

Any updates on this? Any workarounds in the meantime? My script needs 3 parameters. Name, Number, Email.

This has been implemented in the most recent version. You can set parameter values on schedules.

I’m not seeing that option. Can you post a screenshot? If so, I can post a YouTube video once I figure it out to show others.

If i define a script like this:

param(
    $Name,
    $Value,
    $Department
)

You’ll get a UI like this (formatting is messed up for some reason. It’s in our 1.4.3 backlog to fix).

When you create a schedule, it will update the schedules.ps1 like this.

New-PSUSchedule -Cron "* * * * *" -Script "Collect.ps1" -TimeZone "America/Denver" -Name 'Test' -Value 'Test' -Department 'Test'

Thanks. Any idea how I can convert a psm1 file to ps1? It’s got a lot
of functions it used for 1 of the 3 main functions. Right now, I’m
just imp;orting the module and calling the function with the
parameters in the script, causing me to create a new script each time.
It works but I would rather have it working like it is meant to be
used. Thanks for quick response.

You could create a script to import the module and call one function and parameterize the script.

For example, if you had a module that had a write-name function.

function Write-Name {
   param($Name) 

   Write-Host $Name
}

You could then create a script that took that parameter.

param($Name) 

Import-Module .\MyModule.psm1

Write-Name -Name $Name

Then you could setup three schedules for the one script.

New-PSUSchedule -Cron '* * * * *' -Script 'MyScript.ps1' -Name 'Adam'
New-PSUSchedule -Cron '*/5 * * * *' -Script 'MyScript.ps1' -Name 'Ted'
New-PSUSchedule -Cron '*/15 * * * *' -Script 'MyScript.ps1' -Name 'Bill'