Action Plan:

 

  1. Please upgrade the agent first by running the following command line.

 

msiexec /i MOMAgent.msi /qn /l*v "C:\New folder\amd64\AgentUpgrade.log" AcceptEndUserLicenseAgreement=1

 

https://docs.microsoft.com/en-us/system-center/scom/deploy-upgrade-agents?view=sc-om-2019

 

  1. Now we need to add the management group and management server name by following any of the below process.
  2. You can use the following management pack which is very useful in this kind of requirement. You just need to import it on you SCOM 2012 R2 infra where all the agents are reporting currently.

 

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

 

You can download the MP from here: https://gallery.technet.microsoft.com/SCOM-Agent-Management-b96680d5

 

Or you can run the below PowerShell code from your SCOM 2012 R2 management servers to add the management group and management server name.

 

#Powershell script. Save it with a .ps1 extension

# Please put the server name in the text file called Servers.txt and kept it in C:\Software folder.

# Please change the ManagementGroupName and SCOMManagementServerNamewithFQDN

$servers = Get-Content -path "C:\Software\Servers.txt" #Save the list of servers; one in each line

foreach($server in $servers)

    {

        Invoke-Command -ComputerName $server -ScriptBlock{

        $OMCfg = New-Object -ComObject AgentConfigManager.MgmtSvcCfg

        $OMCfg.AddManagementGroup("ManagementGroupName","SCOMManagementServerNamewithFQDN",5723)

        }

    }

 

Additional Information: (Script for Management Group Removal)

 

In case if you want to remove any of the management group information from a specific server, you can use the following PowerShell code. You need to run it from any of the management server.

 

#Powershell script. Save it with a .ps1 extension




# Please put the server name in the text file called Servers.txt and kept it in C:\Software folder.

# Please change the ManagementGroupName to remove it

$servers = Get-Content -path "C:\Software\Servers.txt" #Save the list of servers; one in each line

foreach($server in $servers)

    {

        Invoke-Command -ComputerName $server -ScriptBlock{

        $OMCfg = New-Object -ComObject AgentConfigManager.MgmtSvcCfg

        $OMCfg.RemoveManagementGroup("ManagementGroupName") 

       }

    }