Have a powershell script that will create a scheduled task, for deployment, by way of Octopus, to a Windows 2012 server.
Function Create-ScheduledTask($TaskN
schtasks.exe
won't allow you to do this via basic switches. In order to be able to do this with schtasks.exe
you can use an XML import, of an existing task, as mentioned on SU.
Take an export of an existing task with the trigger set you want that you can import later. PowerShell can also natively understand xml files via the [xml]
cast and Select-XML
so you are not limited to static XML files but can also make changes on the fly to existing ones if you wanted.
Depending on what system you are working from you can also have access to the PowerShell task manipulation cmdlets like Register-ScheduledTask which does allow multiple tasks to be configured. These can be found on Windows Server 2012 R2 and Windows 8.1. To pull a small snippet from TechTarget
$triggers = @() $triggers += New-ScheduledTaskTrigger -Daily -At 03:00 $triggers += New-ScheduledTaskTrigger -Daily -At 09:00 $triggers += New-ScheduledTaskTrigger -Daily -At 15:00 $triggers += New-ScheduledTaskTrigger -Daily -At 21:00 #..... code truncated to only show trigger portion $action = New-ScheduledTaskAction -Execute $pstart -Argument $actionscript Register-ScheduledTask -TaskName $taskname -Action $action -Trigger $triggers -RunLevel Highest -Description “Test job”
Since you tagged 2012 you might be able to run those cmdlets in a PSSession from your own system if it is not 8.1