salt.states.win_task

State module for adding and removing scheduled tasks using the Windows Task Scheduler.

salt.states.win_task.absent(name, location='\\')

Delete a task from the task scheduler.

New in version 3007.0.

Parameters:
  • name (str) -- The name of the task to delete.

  • location (str) -- A string value representing the location of the task. Default is "\" which is the root for the task scheduler (C:WindowsSystem32tasks).

Returns:

True if successful, otherwise False

Return type:

bool

CLI Example:

test_win_task_absent:
  task.absent:
    - name: salt
    - location: ""
salt.states.win_task.present(name, location='\\', user_name='System', password=None, force=False, **kwargs)

Create a new task in the designated location. This function has many keyword arguments that are not listed here. For additional arguments see:

New in version 3007.0.

  • edit_task()

  • add_action()

  • add_trigger()

Parameters:
  • name (str) -- The name of the task. This will be displayed in the task scheduler.

  • location (str) -- A string value representing the location in which to create the task. Default is "\" which is the root for the task scheduler (C:WindowsSystem32tasks).

  • user_name (str) -- The user account under which to run the task. To specify the "System" account, use "System". The password will be ignored.

  • password (str) -- The password to use for authentication. This should set the task to run whether the user is logged in or not, but is currently not working.

  • force (bool) -- Overwrite the existing task.

Returns:

A dictionary containing the results of the state

Return type:

dict

CLI Example:

test_win_task_present:
  task.present:
    - name: salt
    - location: ""
    - force: True
    - action_type: Execute
    - cmd: "del /Q /S C:\\Temp"
    - trigger_type: Once
    - start_date: 12-1-16
    - start_time: 01:00