Scheduleing DPM script from Powershell

Suppose you want scripts to run it on a schedule or even schedule itself. Whilst there is this wonderful Powershell Pack that includes a module to utilize the task scheduler from Powershell. “There’re two things to pay attention to; the length of the schedule command and spaces in path names. A command cannot exceed 260 […]

Suppose you want scripts to run it on a schedule or even schedule itself. Whilst there is this wonderful Powershell Pack that includes a module to utilize the task scheduler from Powershell. “There’re two things to pay attention to; the length of the schedule command and spaces in path names. A command cannot exceed 260 characters. Running Powershell command from DPM binary path requires ~80 character script path, similar for console initialization file and few dozen for complete “Schtasks” command. So we’ve a ~200 character command line leaving ample room for parameters you may need to pass to scheduled script. Here’re some ways to overcome that: Put command to schedule in CMD file and schedule CMD as command; Write script parameters to file and read that file from inside script rather than passing those on command line; Use Powershell Pack which builds task using multiple Powershell statements rather than single command line; Reduce command by facilitating Powershell requirements from within script itself rather than using “–PSconsolefile” parameter.” notes Microsoft.
To schedule itself run script with the –schedule switch as: \script.ps1 –schedule
To schedule another script run as: \script.ps1 –schedule “<path>\ScriptToSchedule.Ps1”

More info: How do I schedule a DPM script from Powershell?