top of page

Operations Management Suite agent deployment with Powershell for Azure VMs

This post was originally published to Martynas' personal cloud blog MagicMarty.eu. 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:

Login-AzureRmAccount

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 MagicMarty.eu 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 info@elastabytes.com to set up a chat with one of our architects.

You can follow us on Twitter @elastabytes.

 

Featured Posts
Recent Posts
Archive
Search By Tags
No tags yet.
Follow Us
  • LinkedIn Social Icon
  • Twitter Basic Square
  • Facebook Basic Square
  • Google+ Basic Square
bottom of page