Windows scheduled task created by puppet

scheduled tasks

While working with puppet in Windows environment sooner or later one will need to create a scheduled task. Especially, it might be very useful to execute activity that requires elevation to local administrator. Below I am presenting two examples for Windows scheduled task creation by puppet. The first is typical backup task. It could be used to backup either file system or database. The second shows SQL server instance installation. It requires elevated permission that can be vary easily achieve by using scheduled task.

BackupTask

  • It is scheduled daily at 9 PM
  • ${msaaccount} it is user used to run the task. Its value is set inĀ puppet external facts for windows
  • d:\Backup.ps1 it is location of script that is going to be run by the task

InstallSqlInstance

  • It is scheduled to be run once 1 min from now
  • ${domainuser} and ${domainpassword it is user, and its password, to run the task. Their values are set in puppet hiera data.
  • User that runs the taks is elevated to local administrator
  • MSSQLSERVER is default SQL Instance, for named instance adjustment is needed
  • d:\installsqlinst.ps1 it is location of the script that is going to be run by the task

Definitely, there are more cases to use Windows scheduled task. The examples showed above can be adjusted to serve other purposes as well.

References:

Leave a Reply