Automate SCOM Group Creation

Creating SCOM Groups can be tedious. Creating dozens of SCOM groups each with multiple members can be a long task indeed.

I searched and searched and thought surely someone somewhere has come up with some Powershell to do this task. I could not find anything. Enter Tao Yang and his OpsMgrSDK Powershell Module. If you are not familiar with this module you need to be. You can read about it and learn how to install it in your environment here

This is a small script using commands from the module. But I will be using this same method for larger scripts getting data from VMM and SCOM in later blog posts.

For this script to work you’ll need a CSV file with three fields filled out for every SCOM Windows Computer Object you want to add to the group.  The computer field needs the FQDN of the server you wish to add to the group. The name field cannot have any spaces so either make it all one word or put periods between words.

Name: My.Awesome.Group
DisplayName: My Awesome Group
Computer: myserver.sandlot.dom

The script will attempt to find the group first, if it cannot it will create it in the management pack you specific at the beginning of the script. There is a start-sleep after creation of the group, this is to give SCOM the necessary time to create the group before you start adding servers to it. Depending on how fast or slow your environment is, you may need to adjust the value, which is in seconds. In one environment I had to adjust it to over 500 seconds.

# Create SCOM Groups with members from CSV file
# Using Tao Yang's OpsMgr SDK powershell module found here
# Change $SCOM to your SCOM management server, run script on your Management Server where you have the OpsMgr SDK installed.

$groups = import-csv C:newgroups.csv #create CSV file with fields called Name, DisplayName and Computer. Computername must be Fully Qualified Domain Name EG mycomputer.sandlot.dom
#Script will create group if it does not exist
$mpname = "custom.groups" #management pack must exist
$scom = "om01.sandlot.dom" #change to your SCOM management server where OpsMgr module is installed

Import-Module OperationsManager

foreach($group in $groups)
$groupname = $
$groupDisplay = $group.displayname
$computer = $

$verify = Get-scomgroup -DisplayName $groupDisplay

if($verify -eq $null)
$create = new-omcomputergroup -sdk $scom -MPname $mpname -computergroupname $groupname -computergroupdisplayname $groupDisplay
start-sleep -Seconds 120 #you may have to adjust this depending on how fast or slow your SCOM environment is.
$groupadd = New-OMComputerGroupExplicitMember -SDK $scom -GroupName "$mpname.$groupname" -ComputerPrincipalName $computer
} Else {$groupadd = New-OMComputerGroupExplicitMember -SDK $scom -GroupName $verify.fullname -ComputerPrincipalName $computer}


I am so thankful for Tao Yang creating this module. It has saved me so much time. Once the groups are created you can this create aggregate Health roll-ups, I believe the module attempts to do this but my results have been mixed.

Lastly, the module and this script work in both SCOM 2012 R2 and SCOM 2016.

Hi, I’m Billy York.  I work in Cloud and Datacenter, specializing in monitoring and automation. Here you’ll find posts about System Center Operations Manager, Powershell, Hyper-V, Azure Automation, Azure Log Analytics and other Microsoft related technologies.