Migrate SCOM agents between management groups

We’re rolling out a new SCOM environment, and I need to migrate/multi-home agents between our existing management group and the new one. Is there a good way of doing this without manually logging on and modifying the MG settings on each agent? Arrrgghhh, help please!

1 Like

Hi

Were going through the same exercise and this was a great help indeed…

https://blogs.technet.microsoft.com/kevinholman/2017/05/09/agent-management-pack-making-a-scom-admins-life-a-little-easier/

Thanks

6 Likes

it’s 2017, you don’t log in interactivly any more do you? :slight_smile:

You can add management group through the agent using powershell, and this powershell script could be added as a agent task within SCOM which makes you add the new MG from the console. Below is a PS script function to do it, but it wont be a task straight out of the box.

http://adatum.no/operationsmanager/script-to-add-scom-agent-management-group

<#

.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()

Also, a little info on the Agent task ‘issue’

http://adatum.no/operationsmanager/scom-task-to-restart-agent-am-i-complicating-it

2 Likes

Is it no longer as easy as running the discovery from the new MG’s console and “installing” the agent (adding MG info) that way?

1 Like

Afternoon All,

I had a read through this as we have recently done the exact same thing for a global customer.

Basically you can use SCOM to give you all the information by creating as simple Management Pack. First create an Attribute. The Attribute (Extend the Computer Class) looks at the registry and then populates a view (New View with Extended Class as property) and with this view you are able to easily see which machines are multihomed or compliant in relation to you new and old Management Group.

Then build a task (VBScript - old school :D) that adds the additional configuration into the registry. I prefer this way as when running PowerShell scripts, there is an execution policy that can catch you out. Then when you have the view sorted into the machines that require the new Management Group, select them all and simply run the task. This will add the Management Group to all the non-compliant machines.

Actually, ignore getting it from me. Jimmy Harper has your solution here. I must have copied it from him. All kudos for the solution must go to him:

https://blogs.technet.microsoft.com/jimmyharper/2016/08/13/scom-task-to-add-or-remove-management-groups-on-agents/

2 Likes

I agree, we migrated from 2012 to a new 2016 environment and utilized this MP to handle the Management Group Agent Homing.

Absolutely! But the wizard isn’t particularly fast and it wouldn’t do too well with a large number of agents. The MP above will probably just add a new registry entry for the new MG and restart the agent, much quicker than the wizard :wink: