Azure Automation vs Task Scheduler

Azure Automation vs Task Scheduler

An introduction to Azure Automation

Play this article

Task scheduler has been used within Windows for years for businesses to run scripts regularly and it has faired that purpose well. Perhaps there is another way of running PowerShell scripts, that's where Azure Automation comes in.

Azure Automation is a cloud solution which allows you to run PowerShell and Python scripts either in the cloud or on-premises via a hybrid worker. These scripts can either be triggered via a webhook or on a schedule, which is what we will cover here.

Benefits of Azure Automation

  • Improved visibility over failed jobs, using alerting.

  • View any output and errors using a console window.

  • Connect to a source control repository for easier script updates and to keep the history of updates over time.

  • Provides the storage of credentials and encrypted variables to be used within scripts for improved security.

Benefits of Task Scheduler

  • You can run a PowerShell script within an administrator prompt which Azure Automation does not allow.

Setting up an Automation Account

Creating an Azure Automation Account is simple. Just go to Automation Accounts \>> Create.

Enter the required information for the new account:

  1. Subscription to place/bill the resource in.

  2. Create a new/select resource group to place the resource in.

  3. Name for the Automation Account.

  4. The region to create the resource in.

  5. Review + Create.


Scripts within Azure Automation are called runbooks. These can be different types, the main ones are PowerShell and Python.

To create a new runbook go to the runbooks blade within your Automation Account \>> Create a Runbook.

You then enter the information for your new runbook, its name, type, and runtime version.

You can enter some content for your new runbook and then save/ publish it. To start your runbook click on the start button to run the runbook.

When the script has run the status will change to completed, or failed if there was an error. From the job, a runbook that has been run, page you can select the output tab to view the console output, where you have used the Write-Output cmdlet for example.


Variables allow you to store information centrally that can be used within your scripts. It also allows you to encrypt if needed, if it's an API key for example.

To create a new variable simply provide a name, its type, value and whether it's encrypted or not.

If the variable is encrypted you will not be able to view its value from within the Azure portal.

To retrieve the variable value within a PowerShell script:

Get-AutomationVariable -Name "MyVariable"


Credentials allow you to store a username and password within Azure Automation.

To create a new credential provide a name for it, the username and password.

To retrieve the credential within a PowerShell script:

Get-AutomationPSCredential -Name "MyCredential"


Certificates can be used for authenticating within PowerShell. To create a new certificate provide a name, and either a .cer or .pfx file for the certificate.

To retrieve a certificate within PowerShell:

Get-AutomationCertificate -Name "MyCertificate"


The modules blade allows you to add modules that are not installed by default, 'ExchangeOnlineManagement' for example. You can install a module directly from the PowerShell gallery or from a zip file of a module you have locally.

Once a module is installed you can use the cmdlets from within it as you normally would in your scripts.


Schedules are exactly what they sound like. Just as you would in task scheduler you select a date/time for the schedule to start and if it is to be reoccurring how often.

Open the runbook you which to add to your schedule and select the 'Link to Schedule' option.

You can select your schedule and also any parameters for your runbook when it runs.

Hybrid Workers

If your scripts don't need to run on-premises then you can run them within your Azure Automation. If you do need to run them on-premises e.g. if they change something in Active Directory, then you will need to set up a hybrid worker.

A hybrid worker is an on-premises server that is linked to your Automation Account and checks every 30 seconds for new scripts to run.

For more information on hybrid workers follow this link to the Microsoft docs on the subject.