Friday, June 29, 2012

[OpsMgr 2007R2] Get member count of all SCOM groups and export result in txt file - Powershell script

Here is a new short script I had to provide this morning to be able to count members is all SCOM group in my management group.

  1. $mg = (Get-ManagementGroupConnection).ManagementGroup
  2. $groups = $mg.GetRootPartialMonitoringObjectGroups() | sort DisplayName
  3. foreach($group in $groups) {
  4.        $groupMembers = $group.GetRelatedPartialMonitoringObjects([Microsoft.EnterpriseManagement.Common.TraversalDepth]::OneLevel)
  5.        $groupMembersCount = $groupMembers.count.ToString()
  6.        $Msg = $group.DisplayName + "|" + $groupMembersCount
  7.        #$Msg
  8.        $Msg >> C:\SCOMGroupsMembersCountInProduction.txt
  9.  }
Result will be stored in C:\SCOMGroupsMembersCountInProduction.txt text file and will look like :

agent group|3613
Agent Managed Computer Group|3613
Agentless Managed Computer Group|0
All Business Critical Windows Clients|0
All Computers in Management Pack Microsoft System Center Configuration Manager 2007|340
All Computers in ManagementPack: Microsoft.IdentityIntegrationServer|14
All VmWare servers|1332
All Windows Computers|3631

This posting is provided "AS IS" with no warranties.

No comments:

Post a Comment