Azure automation runbook to install OMS agent to enable OMs monitoring.

This script/runbook can help you to install OMs agent on any of VM and enable monitoring for that particular VM instance.

Refer MS gallery for full script –

Once you have the code downloaded from above link then just create new runbook inside azure automation account and copy that code to runbook as it is and start runbook . Once you click on start the runbook will prompt you for few details like workspace name, vm name, resource group name and then it will connect vm to OMS workspace.


  • The runbooks work with an Azure Run As account. The Run As account is the preferred authentication method since it uses certificate authentication instead of a password that may expire or change frequently.
  • This solution can only manage VMs that are in the same subscription as where the Automation account resides. but if in case you want to manage vm from another subscription then that is possible , you just need to add another subscription connect asset and have to add code to connect another subscription before get-azurermvm commands
  • This solution must need OMS installed in subscription
  • you must Need AzureRM.OperationalInsights module in azure automation account to perform this operation.

Refer MS gallery for full script –

(Visited 3 times, 1 visits today)

By Arun Sabale

Arun is a Solution Architect on enterprise client management with more than 14 years of experience in IT. Arun Sabale is Blogger and tech enthusiast. His main focus is on Azure cloud infra, Cloud automation with powershell, python, ARM terraform and all cloud infra services like compute, storage, network, automation, function api etc... LinkedIN -

Comments are closed.