Please reload

Recent Posts

How to Change the Data Retention Period for Log Analytics in Operations Management Suite

January 12, 2017

Please reload

Featured Posts

Operations Management Suite agent deployment with Powershell for Azure VMs

October 31, 2016


This post was originally published to Martynas' personal cloud blog You can read it here.


Azure provides easy way to deploy Operations Management Suite (OMS) agents on Azure VMs. All you need to do is to navigate to Log Analytics blade, choose Virtual Machines from Data Sources and select which VMs you want to add to OMS workspace by clicking Connect on the VM.




But what if you have hundreds or even thousands of VMs running on Azure? This is not going to be an easy task to click on each VM and connect to OMS workspace. Powershell is the answer! With the code below you will be in a good shape to deploy OMS extensions to all VMs on all Resource Groups in your subscription.


Powershell script to deploy OMS monitoring extensions:





Select-AzureRmSubscription -SubscriptionId $SubID


$Settings = @{"workspaceId"="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"};

$ProtectedSettings = @{"workspaceKey"="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"};


$RG = Get-AzureRmResourceGroup


foreach ($Resource in $RG.ResourceGroupName)



 $VMs = Get-AzureRmVM -ResourceGroupName $Resource


 ForEach ($VM in $VMs)



  Set-AzureRmVMExtension -ExtensionType MicrosoftMonitoringAgent -Name MicrosoftMonitoringAgent -Publisher Microsoft.EnterpriseCloud.Monitoring `

        -ResourceGroupName $Resource -TypeHandlerVersion 1.0 -VMName $VM.Name -Location $VM.Location -ProtectedSettings $ProtectedSettings -Settings $Settings







Good Luck!



Martynas is a Senior Cloud Solutions Architect at Elastabytes. He's a Lithuanian who loves the gym, poker, and Cloud and Hybrid Cloud solutions.


He has his own blog and is the co-organiser of the UK Cloud Infrastructure User Group.


You can follow him on twitter @CloudMagicMarty.

Elastabytes are a cloud managed services company specialising in SQL Server.  We’re a Microsoft Gold Partner and our team is made of Microsoft MVPs. Whether you’re already in Azure and need a DBA-as-a-Service, or you’re about to go to Azure and need a hand getting there, Elastabytes can help.


Contact us at to set up a chat with one of our architects.


You can follow us on Twitter @elastabytes.



Share on Facebook
Share on Twitter
Please reload

Follow Us
Please reload

Search By Tags
Please reload

  • LinkedIn Social Icon
  • Twitter Basic Square
  • Facebook Basic Square
  • Google+ Basic Square
  • LinkedIn Social Icon
  • Twitter Social Icon
  • Facebook Social Icon
  • Google+ Social Icon

© Elastabytes Ltd 2017