Ask Your Question

Use of Windows resource scheduled_task

asked 2018-08-16 12:46:33 -0600

pkrawetzky gravatar image

updated 2018-08-27 11:50:24 -0600

binford2k gravatar image

I am trying to use the windows resource scheduled_task. I don't want to create the task in the default location but instead I want to put it in it's own library name. No matter what I try, I get the following error:

Error: Failed to call #<Win32::TaskScheduler::COM::TaskScheduler:0x000000093d2580>::NewWorkItem with HRESULT: -2147024893.:  The system cannot find the path specified.
Error: /Stage[main]/Puppet_agent::Init_windows/Scheduled_task[\Task Scheduler\Task Scheduler Library\Puppet\PuppetKickoff]/ensure: change from absent to present failed: Failed to call #<Win32::TaskScheduler::COM::TaskScheduler:0x000000093d2580>::NewWorkItem with HRESULT: -2147024893.:  The system cannot find the path specified.

Here is my code:

scheduled_task { '\Task Scheduler\Task Scheduler Library\Puppet\PuppetKickoff':
  ensure    => present,
  enabled   => true,
  command   => 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
  arguments => ' E:\\Program Files\\PuppetLabs\\bin\\run_puppet_shell.bat -Verb runas',
  trigger   => {
    schedule   => daily,
    every      => 1,            # Specifies every other day. Defaults to 1 (every day).
    start_date => '2018-08-15', # Defaults to 'today'
    start_time => '08:${puppet_agent::params::cronminute}',      # Must be specified
    minutes_interval => '60',   # Repeat this task every 60 minutes
    minutes_duration => '300',  # The task will run for a total of five hours

If want a Puppet library with the scheduled task PuppetKickoff to appear there, how do I define the name? I've tried several variations including \Puppet\PuppetKickoff but nothing seems to work, always getting the same error.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-29 00:19:42 -0600

joshc gravatar image

Puppet's builtin scheduled_task resource only supports v1 of the task scheduler API, so you can't specify different directories for the task. The new scheduled_task module supports v2 while providing backwards compatibility with v1. That said, it doesn't support specify the folder. I suggest filing a MODULES ticket at "" and set the component to scheduled_task.

Unrelated if you're using single quotes, then you shouldn't escape the backslashes, so just 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'. The only time you need to escape backslashes in puppet manifest is if it's a double quoted string, which usually occurs when interpolating a string like the system32 fact: "${system32}\\WindowsPowerShell\\v1.0\\powershell.exe"


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-08-16 12:46:33 -0600

Seen: 174 times

Last updated: Aug 29