Powershell – pass paramter to Schtasks

powershellscheduled-tasktask-schedulerwindows-server-2008

how can i run schtasks from command line such that i can pass in parameters during run time.
i have a batch job which expects parameters during run-time that is created in scheduled task. i cannot have a fixed parameter so i cannot provider the parameter when i first create the task i need to provide this during the run time.
i was hoping if there is a way to do like, i need to run this task from schtasks using command line, because i can set the task to run as Admin and give user with less role invoke the task on demand

schtasks /Run /Tn "task" /parameter....?

Best Answer

Here is an example of parameter passing with schtasks:

schtasks /create /tn "test" /TR "\"C:\Program Files\SyncToy 2.1\SyncToyCmd.exe\"-R" /sc daily /st 08:00:00