Add a Management Group to a SCOM 2012 R2 Agent via Script

Here’s a handy script you can use to add a management group to a server that already has a SCOM agent on.

If you save the below as a VBS (Be sure to edit the Management group and server name in bold)

Option Explicit

Dim objMSConfig

Set objMSConfig = CreateObject(“AgentConfigManager.MgmtSvcCfg”)

Call objMSConfig.AddManagementGroup (“MGName“, “Servername.test.com“,5723)

Now if you run the VBS script locally on the server with a SCOM agent it will now add the management group.

If you are in a situation where you need to add a management group to multiple servers, you can do this in the following way.

  1. Download PSEXEC (https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx)
  2. Place the VBS you saved earlier onto a file share (In this example that will be TestFileServerSCOMMGAdd.vbs)
  3. Now open command prompt and map to the location where PsExec.exe is located
  4. Simply Run PsExec.exe Server1,Server2 -s cscript.exe “TestFileServerSCOMMGAdd.vbs” (Change the Server names to the servers you wish to add the management group to, making sure each server name is separated by a comma)
  5. The Management Group should be added J

     

About the author