Adding a second trigger in task schedule

后端 未结 2 1866
旧巷少年郎
旧巷少年郎 2021-01-05 23:33

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         


        
2条回答
  •  醉话见心
    2021-01-05 23:52

    I have similar task and most elegant solution that I found was to create the schedule task at test environment /local PC using the GUI and export it as XML. Then copy the XML formatted text and embedded it into the script, after execution the script save this string block as XML file locally and run schtasks.exe to create the new task.

    schtasks.exe /create /RU "NT AUTHORITY\SYSTEM" /TN TaskName /XML "XMLFolder\TaskName.xml"
    

提交回复
热议问题