Menu Close

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


We have some REALLY good documentation on this here:


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

# Add OMS Workspace

# Remove OMS Workspace

# Get the OMS proxy if configured

# Set a proxy for the OMS Agent

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



  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”)

  2. Manny

    Hi Kevin,

    We’d like to connect the scom 2019 servers to azure log analytics and we get an error connecting to…..

    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.