How to schedule on Azure to run a powershell script on different VMs in specific hours.

Marcus Assis 0 Reputation points
2024-12-27T22:19:26.7933333+00:00

Hi.

I need to run a PowerShell script in different servers and different hours for each VMs. For exemple, Server A must run at 3pm, Server B must run at 5pm and Server C must run at 11am. I can run the PowerShell script successfully on "Run Command", but I couldn't schedule the automation to run it.

Can you please give me a suggestion on how to do it?

Thanks in advance!

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,211 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,288 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,521 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,597 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,721 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Leo Visser 91 Reputation points MVP
    2025-01-10T03:46:23.3033333+00:00

    If you want to run PowerShell scripts from Azure on the VM itself you will need to use a Hybrid Worker Group:
    https://zcusa.951200.xyz/en-us/azure/automation/automation-hybrid-runbook-worker?sharingId=MVP_307251

    You can create this in a Azure Automation Account. Once you created the account you can then create this hybrid runbook worker group. You will need to create a group for every machine you want to run seperate scripts on.
    Once that is done you can run a runbook (PowerShell script) on this worker group:
    https://zcusa.951200.xyz/en-us/azure/automation/automation-hrw-run-runbooks?sharingId=MVP_307251

    You can then create a schedule in the azure automation account. Here you can specify to run the script at specific times in on the hybrid worker group

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.