Forum Discussion

Dante Nahuel Ciai's avatar
Dante Nahuel Ciai
Brass Contributor
Jan 23, 2018
Solved

Connect OMS on multiple VMs

Hi all I'm managing a subscription with 400 VMs. I need to connect them all to one OMS workspace.   Is there any way to perform this by Powershell without manually connecting one by one in the...
  • Hi, Yes it is possible. The command will depend on the OS - Linux or windows but in general here is the code for Windows:

     

    [string]$Settings          ='{"workspaceId":"' + $OMSLogAnalyticsWorkspaceID + '"}';
    	                [string]$ProtectedSettings ='{"workspaceKey":"' + $OMSLogAnalyticsPrimaryKey + '"}';
    
    
    Set-AzureRmVMExtension `
                                                    -ResourceGroupName $ResourceGroupName `
                                                    -VMName $VMName `
                                                    -Name 'Microsoft.EnterpriseCloud.Monitoring' `
                                                    -Publisher 'Microsoft.EnterpriseCloud.Monitoring' `
                                                    -TypeHandlerVersion '1.0' `
                                                    -ExtensionType 'MicrosoftMonitoringAgent' `
                                                    -Location $Location `
                                                    -SettingString $Settings `
                                                    -ProtectedSettingString $ProtectedSettings 
    

    For Linux is similar, only extension type is different OmsAgentForLinux and the name can be changed as well.

Resources