Script to add SCOM agent management group
We wanted to change how SCOM agents is installed and configured. That involved some scripting. As a part of the process we add a management Group to the agent after it is installed. SCOM 2016 is also released now so if you want to migrate instead of upgrading, you can use this script to add an additional MG.
Script will have two mandatory parameters management server and management Group name. A Third parameter is optional, which is the port number and defaults to 5723. You can save the below script as Add-SCOMManagementGroup.ps1
<# .SYNOPSIS Adding management group to agent .DESCRIPTION Adding first or additional management group to agent. for example use this to multihome agent when migrating to a new management group. .EXAMPLE Add-SCOMManagementGroup.ps1 -ManagementServer SCOM01.domain -MGMTGroupName SCOMMG Adds SCOMMG to the agent and set SCOM01 as primary management server. Default port 5723 .EXAMPLE Add-SCOMManagementGroup.ps1 -ManagementServer [Primary MS] -MGMTGroupName [Management group name] -port [INT] Adds SCOMMG to the agent and set SCOM01 as primary management server and set port you specify .NOTES Author: Martin Ehrnst /Intility AS #> Param( [Parameter(Mandatory=$True)] [string]$ManagementServer, [Parameter(Mandatory=$True)] [string]$MGMTGroupName, [Parameter(Mandatory=$false)] [int]$Port = "5723" ) $ErrorActionPreference='Stop' Write-Warning "This will restart the agents health service" #Adding MG to the agent try{ $Agent = New-Object -ComObject AgentConfigManager.MgmtSvcCfg $Agent.AddManagementGroup("$MGMTGroupName", "$ManagementServer", "$Port")} catch{ CLS Write-host "An error occured please se exeption message:" Write-error $_.Exception.Message BREAK } get-service HealthService | Restart-Service Write-Host "Agent connected to the following management groups" $Agent.GetManagementGroups()
2 COMMENTS
The point of view of your article has taught me a lot, and I already know how to improve the paper on gate.oi, thank you. https://www.gate.io/es/signup/XwNAU
I may need your help. I’ve been doing research on gate io recently, and I’ve tried a lot of different things. Later, I read your article, and I think your way of writing has given me some innovative ideas, thank you very much.