Skip to content

An Azure DevOps extension for installing and uninstalling Windows Scheduled Tasks

License

Notifications You must be signed in to change notification settings

deadlydog/AzureDevOps.WindowsScheduledTasks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows Scheduled Tasks Azure DevOps Extension

This Azure DevOps (i.e. TFS) extension provides Build and Release Pipeline tasks that allow Windows Scheduled Tasks to easily be installed, uninstalled, enabled, disabled, started, and stopped on the local or remote computer(s).

Current build status: Build Status Deployment Status

Features

  • Install a Windows Scheduled Task by specifying properties inline, XML inline, or from an XML file.
    • Replace an existing Windows Scheduled Task of the same name by overwriting it.
  • Enable, Disable, Start, Stop, and Uninstall a Windows Scheduled Task.
    • Supports wildcards for modifying many Schedules Tasks easily, or when you only know part of the Scheduled Task's name.
  • Multiple computers can be specified to easily run the task against all of them.
  • Supports connecting to remote computers via WinRM using many authentication options, such as CredSSP, as well as both HTTP and HTTPS.

Requirements

The computer running the Azure DevOps agent must meet the following minimum requirements:

  • Be running PowerShell 3 or greater.
  • The user that the Azure DevOps agent runs as must be an admin on the computer the Scheduled Task is being installed on.

The computer that will be hosting the Windows Scheduled Task must meet the following minimum requirements:

If the Windows Scheduled Task is on a remote computer, it must also meet these requirements:

  • Have Windows Remote Management 3.0 or later installed, as Windows PowerShell uses WinRM to connect to remote computers.
  • You may need to enable PowerShell Remoting on the remote computer by running Enable-PSRemoting from an administrator PowerShell command prompt on the remote computer.

For more information, read Microsoft's documentation.

Authentication options for connecting to a remote computer

All authentication mechanisms supported by the Invoke-Command PowerShell cmdlet are supported, such as Basic, CredSSP, Digest, Kerberos, Negotiate, and NegotiateWithImplicitCredential.

If you are connecting to a remote computer and want to use CredSSP, it must have CredSSP enabled on it. You can do this by running the following command from an administrator PowerShell command prompt on the remote computer:

Enable-WSManCredSSP -Role Server -Force

More information about the authentication types can be found here.

Defining the Scheduled Task definition properties

When installing a Scheduled Task, you have a few different options for how to define the Scheduled Task properties:

  1. Use an XML file (recommended best practice):

    • Not all Scheduled Task properties can be specified inline. If you want to configure properties that are not available inline, you must use XML.
    • Using an XML file allows you to have the Scheduled Task definition committed to source control alongside your code so you can track changes to it.
  2. Use Inline XML:

    • Not all Scheduled Task properties can be specified inline. If you want to configure properties that are not available inline, you must use XML.
    • No need to include an XML file in your source control or build artifacts for the deployment to use.
  3. Define all of the properties Inline in the Build/Release task:

    • Convenience and ease of use; no need to generate XML.
    • No need to include an XML file in your source control or build artifacts for the deployment to use.

When using XML you will still need to specify the Scheduled Task Name and User To Run As.

How to create your Scheduled Task XML definition file

If your Scheduled Task already exists in the Windows Task Scheduler, simply right-click on the Scheduled Task and choose Export.

Export Windows Scheduled Task screenshot

If your Scheduled Task does not already exist, create a new Scheduled Task in the Windows Task Scheduler, configure it the way you want, test it (if possible), and then export the XML file.

If you prefer, you can also export the Scheduled Task via the Export-ScheduledTask PowerShell cmdlet.

Feedback

Ratings and feedback are very much appreciated. If you have a spare moment, please leave a review.

If you encounter problems or would like to request new features, please do so on the GitHub issues page, as it facilitates discussions much better than the marketplace Q&A and Rating/Review pages.

You can view the change log here.

Implementation

Under the hood this extension uses the PowerShell ScheduledTasks cmdlets, so the functionality it can offer is limited to what those cmdlets provide.

Changelog

See what's changed in the extension over time by viewing the changelog.

Additional ideas to implement

  • Add option to specify if "Can't find task with the given path and name" should be treated as a warning or an error.

Donate

Buy me some maple syrup for providing this extension open source and for free :)

paypal