Menu Close

Adding direct agent Log Analytics Workspace (OMS) and Proxy via PowerShell


image

We have some REALLY good documentation on this here:  https://docs.microsoft.com/en-us/azure/log-analytics/log-analytics-windows-agents

 

PowerShell and the Agent Scripting Objects make it really easy to control the Log Analytics (previously OMS) MMA direct agent configuration on thousands of agents, using SCOM.

 

Here are some PowerShell examples:

# Load agent scripting object
  $AgentCfg = New-Object -ComObject AgentConfigManager.MgmtSvcCfg

# Get all AgentCfg methods and properties
$AgentCfg | Get-Member

# Check to see if this agent supports OMS
  $AgentSupportsOMS = $AgentCfg | Get-Member -Name ‘GetCloudWorkspaces’

# Get all configured OMS Workspaces
  $AgentCfg.GetCloudWorkspaces()

# Add OMS Workspace
  $AgentCfg.AddCloudWorkspace($WorkspaceID,$WorkspaceKey)

# Remove OMS Workspace
  $AgentCfg.RemoveCloudWorkspace($WorkspaceID)

# Get the OMS proxy if configured
  $AgentCfg.proxyUrl

# Set a proxy for the OMS Agent
  $AgentCfg.SetProxyUrl($ProxyURL)


I added these tasks to ADD and REMOVE Log Analytics workspaces from the MMA, in the latest version of the SCOM Management helper pack:

https://kevinholman.com/2017/05/09/scom-management-mp-making-a-scom-admins-life-a-little-easier/

image

3 Comments

  1. Joe Thompson

    This code can easily be converted to adding and removing SCOM management groups from SCOM agents. Just need to use the AddManagementGroup and RemoveManagementGroup methods using the vbs examples…

    $hsConfig = New-Object -ComObject ‘AgentConfigManager.MgmtSvcCfg’
    # uncomment next line if you want to remove a mgmt. group while adding a new management group
    # $hsConfig.RemoveManagementGroup(“SCOM2012R2LAB”)
    $hsConfig.AddManagementGroup(“SCOM2019LAB”,”scomsql01.corp.com”,5723)
    $hsConfig.ReloadConfiguration()

  2. Manny

    Hi Kevin,

    We’d like to connect the scom 2019 servers to azure log analytics and we get an error connecting to https://weu.service.opinsights.azure.com/Config…..

    This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.

    What should we do/check/verify?

    I found a couple of recent threads about this, but no cause or solution.
    This is not about scom agents to azure. We don’t want that to happen.

    Please advice

Leave a Reply

Your email address will not be published.