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/