Table of contents
Introduction
To run the Octopus programs automatically, you need to create a Windows scheduled task. This article will provide you with guide lines to do so.
Related Articles
- ADSIReader
- Import from Active Directory
- DataImporter
- Import from an ODBC source
- GetDB
- Download the Octopus database
- MailIntegration
- Creation of incidents/events from emails
- WMIUpdater
- Updating the computer configuration
Prerequisites
- Identify the computer that will be used to execute the Octopus program. We recommend the use of a server, or minimally a computer that is always turned on
- Plan occurrences under which the program should run automatically
- Pay special attention to scheduling conflicts with other scheduled tasks like backups or reboots, especially in case of data transfer
- MailIntegration should be run according to your environment and your response targets, between 3 to 10 mintues
- Check not to run the task again if it is already running.
- Determine the access level of the batch file user
- WMIUpdater needs to be run by an user with administrator rights on the targeted computers (usually domain admin)
- An option is to create a Windows account to run the scheduled tasks
Programing the scheduled task
- Create a batch file containing the commands and associated parameters that you wish to use
- You can add multiple commands one after the other to perform many operations
- We recommend the use of a batch file because it is easier to modify this file then to change the scheduled task
- Validate that the batch file works before going forward with the automation
- Refer to the operating system documentation of the machine used to run the scheduled task to edit the batch file
- Create a scheduled task that will run the batch file according to the schedule
- Access the task manager from Control Panel > Administration Tools > Scheduled Tasks
- Create a new task
- Give it a significant name
- Depending on the size of your IT environment, there could be several other tasks present
- Select the schedule and the frequence of execution according to what you have previously determined
- In the program field, add the name of the batch file previously created
- The parameter field can stay empty
- Specify the account to be use to run the task
- You will need to enter the password each time you need to modify the scheduled task
- Keep the password in a secure place. If the password changes, you will need to update it for each scheduled task
- Refer to the operating system documentation of the machine used to run the scheduled task to configure the schedualed task
- Test the scheduled task right away. The program generates a .log file in which the results of the execution can be found; it is located in the Octopus folder. You can also see if the task worked by looking for results directly in Octopus
** If you have several mailboxes, it is generally recommended to have a single Windows scheduled task that will run a batch file that will launch MailIntegration as many times as you have mailboxes.
Using a Microsoft Entra ID account
Requirements
When Octopus is configured for single sign-on (SSO) with Microsoft Entra ID, the Octopus program run by the scheduled task must authenticate with a Microsoft Entra ID account. This account must meet the following conditions:
- The account must be able to authenticate without multifactor authentication (MFA).
- The scheduled task runs without human intervention, so no one can respond to a multifactor authentication prompt.
- Multifactor authentication must be disabled for this account, or the account must be excluded from the conditional access policies that require it.
- The account must exist in Octopus.
- The account must be created as a user in Octopus with the matching Microsoft Entra ID username (e.g. serviceaccount@domain.com).
- It must have the permissions required by the operations performed by the program.
Testing the account
This feature lets you confirm, before setting up the scheduled task, that the account can authenticate with Microsoft Entra ID without multifactor authentication.
Use the Generate encrypted password for Microsoft Entra ID feature in Octopus:
- Start the Octopus Windows client.
- Open the feature from Tools > Generate encrypted password for Microsoft Entra ID...
- Enter the account's Microsoft Entra ID username and password.
- Click Generate.
- If an encrypted password is displayed, the account successfully authenticated with Microsoft Entra ID without multifactor authentication. It can therefore be used by the scheduled task.
- If an error message is displayed, check the password, the account status and the multifactor authentication or conditional access configuration in Microsoft Entra ID. The user's sign-in logs in Microsoft Entra ID provide more details on the cause of the failure.
- Copy the encrypted password with the copy button to the right of the field.
Using the encrypted password in the batch file
Pass the encrypted password to the /password argument on the Octopus program's command line, and the Microsoft Entra ID username to the /login argument.
Example:
/login:serviceaccount@domain.com /password:<encrypted password>
With these two arguments, the program authenticates in Octopus with this account, regardless of the Windows user running the scheduled task.
Tips and Tricks
To monitor this task, use the free Blat application to end your batch file with an email notification sent to the person responsible of automation.
Thank you, your message has been sent.
