SystemCenter

All about System Center Articles and Tutorials

Bulk Modify Explicit Group Membership through PowerShell – SCOM

Posted by on Mar 28, 2017 in PowerShell, SCOM, SCOM 2012, SCOM 2016

Bulk Modify Explicit Group Membership through PowerShell – SCOM

We were working with one of our clients wherein we migrated their server and application monitoring to Operations Manager 2016.

They had a huge number of servers and manually adding the servers in Group would be a tedious task as it consumes a lot of time. So, we planned to add those servers in Group through PowerShell so we can save some time and avoid any error.

There’s a wonderful Blog written by Russ Slaten where he has described modifying Explicit Group Membership in SCOM 2012 with PowerShell. The good thing is, the provided PowerShell script works with SCOM 2016 as well. You can download the script here: DOWNLOAD

Once you have downloaded the script, rename the script to ModifyGroupMembership.ps1 and save it in C: drive of the Management Server.

Below is the syntax which needs to be used for modifying the Explicit Group membership:

For Adding Objects

.\ModifyGroupMembership.ps1 –ManagementServer ‘MGMTSERVER.domain.com’ –ManagementPackID ‘Overrides.for.SEP’ –GroupID ‘Overrides.for.SEP.group.TEST_Symantec’ –InstancesToAdd ‘417AC11D-2A84-7F63-2E0F-120CB05C7DEC’,’C210B4C8-2112-256A-9EB6-15A58F064894′

For Removing Objects

.\ModifyGroupMembership.ps1 –ManagementServer ‘MGMTSERVER.domain.com’ –ManagementPackID ‘Overrides.for.SEP’ –GroupID ‘Overrides.for.SEP.group.TEST_Symantec’ –InstancesToRemove ‘417AC11D-2A84-7F63-2E0F-120CB05C7DEC’,’C210B4C8-2112-256A-9EB6-15A58F064894′

For Adding and Removing the Objects

.\ModifyGroupMembership.ps1 –ManagementServer ‘MGMTSERVER.domain.com’ –ManagementPackID ‘Overrides.for.SEP’ –GroupID ‘Overrides.for.SEP.group.TEST_Symantec’ –InstancesToAdd ‘417AC11D-2A84-7F63-2E0F-120CB05C7DEC’,’C210B4C8-2112-256A-9EB6-15A58F064894′ –InstancesToRemove ‘E3CA2F1D-4825-51A2-B45B-35670BAB5683’,’4FBBC003-EAB6-B196-4CAA-6B960E6982A6’

Below are the parameters which are required for above cmdlets:

  • Management Server – SCOM Management Server FQDN
  • Management Pack ID – Management Pack ID which needs to be created or Modified.
  • Group ID – Group ID which needs to be created or Modified.
  • Instances to Add – GUID of the objects which need to be added to the group.
  • Instances to Remove – GUID of the objects which needs to be removed from the group.

How to find the Management Pack ID

Method 1: You can find the Management Pack ID under Management Pack Properties as highlighted below.

Method 2: Export the Management Pack on Desktop, open it in Notepad and you will find the Management Pack ID as highlighted below:

How to find the Group ID

Export the Management Pack which holds the Group for which you want to find the Group ID and look for Group name.

You will find the Group ID quoted under ClassType ID as highlighted below:

Group ID is the combination of Management Pack ID (which holds the Group) and the Group Name.

Example:

Management Pack ID: Overrides.for.SEP

Group Name: TEST_Symantec

Group ID will be: Overrides.for.SEP.group.TEST_Symantec (Overrides.for.SEP + .group.TEST_Symantec)

How to find out Object GUID

You can refer below article wherein I have described different ways to find out the GUID of monitored objects:

Find Monitored Object ID in Operations Manager

RUNNING THE SCRIPT

Since now we have all the required parameters, let’s try the script.

Here I am taking a scenario wherein we need to create a Group named “SCMVP_SEPM_Servers” and need to add below objects in the group:

1: Windows Computer
2: Health Service Watcher (Agent)

Will use existing Management Pack ID “Override.for.Windows.OS.MP

Monitored Object GUIDs:

E3CA2F1D-4825-51A2-B45B-35670BAB5683
417AC11D-2A84-7F63-2E0F-120CB05C7DEC
4FBBC003-EAB6-B196-4CAA-6B960E6982A6
C210B4C8-2112-256A-9EB6-15A58F064894
046BC045-5DDA-4DD6-80AB-E9FD19043907
617E6CD8-7ED7-C5E4-D06B-1FC4BA1B11E8
D72B1950-0673-BC21-DAB2-6A78CD44A4AA
FE50D19E-77CE-0C7A-08C3-05FE84EE119C

Based upon the parameters the final cmdlet will be as below:

.\ModifyGroupMembership.ps1 –ManagementServer ‘SYSTEMCENTERMVP.test.com’ –ManagementPackID ‘Override.for.Windows.OS.MP’ –GroupID ‘Override.for.Windows.OS.MP.group.SCMVP_SEPM_Servers’ –InstancesToAdd ‘E3CA2F1D-4825-51A2-B45B-35670BAB5683’,’417AC11D-2A84-7F63-2E0F-120CB05C7DEC’,’4FBBC003-EAB6-B196-4CAA-6B960E6982A6’,’C210B4C8-2112-256A-9EB6-15A58F064894’,’046BC045-5DDA-4DD6-80AB-E9FD19043907’,’617E6CD8-7ED7-C5E4-D06B-1FC4BA1B11E8’,’D72B1950-0673-BC21-DAB2-6A78CD44A4AA’,’FE50D19E-77CE-0C7A-08C3-05FE84EE119C’

The script took only few seconds to create a new group and update the Explicit Group membership.

If we check the Group Explicit membership, we will find all the objects which were added through script.

The same way, we can remove the objects from the group.

The script will surely save your time and you will be able to avoid manual efforts adding/removing servers in a Group.

Hope this helps.

1 Comment

  1. Here you have showed to add for both the below objects in the group:
    1: Windows Computer
    2: Health Service Watcher (Agent)

    But I just want 1: Windows Computer to be added to the group. Then what should I do for that?

Submit a Comment

Your email address will not be published. Required fields are marked *