Forum Discussion
Connect OMS on multiple VMs
Hi Dante,
you can use this.
Add-AzureRmAccount
Set-AzureRmContext -Subscriptionid <Your Sub ID>
$workspaceName = "<Your OMS workspace name>"
$resourcegroup = "<Your OMS’s Resource Group>"
$workspaceId = "<Workspace ID>"
$workspaceKey = "<Key>"
$location = "<OMS workspace location>"
$vms = Get-content -Path "C:\temp\<file name>.txt"
$vmresourcegroup = "<VMs’ Resource Group>"
foreach ($vm in $vms) { Set-AzureRmVMExtension -ResourceGroupName $vmresourcegroup -VMName $vm -Name "MicrosoftMonitoringAgent" -Location $location -Publisher "Microsoft.EnterpriseCloud.Monitoring" -ExtensionType "MicrosoftMonitoringAgent" -TypeHandlerVersion "1.0" -SettingString "{'workspaceId': '$workspaceId'}" -ProtectedSettingString "{'workspaceKey': '$workspaceKey'}" }
put the all VM's name into an TXT or an CSV file the provide the location and then run it into the powershell.
i think this will helpfull.