| How-To: Configure OpsMgr R2 Service Level Tracking on Live Maps views » |
How-To: List Live Maps group information using Powershell
With every view that is build using Live Maps an OpsMgr group is created containing all the objects that are on the Live Maps view. You can use these groups for different purposes, for example target the group for security, reporting, service level tracking or for setting maintenance mode.
In this article it will give a few code examples to extract information about Live Maps groups using Powershell.
Follow up:
Lets get connected
Because I am more familiar programming against the OpsMgr SDK than by using the OpsMgr command shell I will use the SDK approach in this example. First we need to load the OpsMgr SDK assemblies and get connected to the RMS.
1: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.OperationsManager") | Out-Null
2: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.OperationsManager.Common") | Out-Null
3:
4: $rms = "vm-demo-scom01" # set your RMS
5:
6: $className = "Savision.LiveMaps.v3.InstanceGroup"
7: $mpName = "Savision.LiveMaps.v3.Library"
8:
9: $mg = New-Object Microsoft.EnterpriseManagement.ManagementGroup $rms
10: $mp = $mg.GetManagementPacks($mpName)[0]
11: $baseClass = $mg.GetMonitoringClass($className, $mp)
Getting a list of all Live Maps groups
The following code will return a list of all Live Maps groups and tell you in which management pack they are created.
1: # listing all Live Maps group objects and their managementpack
2: $baseClass.GetDerivedMonitoringClasses() | select DisplayName, Name, {$_.GetManagementPack().DisplayName}| Sort DisplayName
Example output:
1: DisplayName Name $_.GetManagementPack().DisplayName
2: ----------- ---- ----------------------------------
3: Dallas Group_7338aac1f07d4b03a1e67ea761c326a2 Savision Live Maps Authoring
4: Dallas - Rack 1.1 Group_92a213a0be004746b9968251875d6f62 Savision Live Maps Authoring
5: Dashboard Group_ea2c324d7d0d4c4781c24b3cf002a40d Savision Live Maps Authoring
6: DNS Servers Group_281728e4ba57488cb807075018b17b59 Savision Live Maps Authoring
7: Domain Controllers Group_40bf030aafe246e6ae93def94939ed8b Savision Live Maps Authoring
Getting the members of each Live Maps group
The next lines of code will return the members of each Live Maps Group and tell you the type of each member.
1: # list all Live Maps group objects and their members + member type
2: foreach($groupClass in $baseClass.GetDerivedMonitoringClasses())
3: {
4: $groupMO = $mg.GetMonitoringObjects($groupClass)[0]
5: Write-Host "----------------------------------------------------------------"
6: Write-Host "Members of group : " $groupMO.DisplayName
7: Write-Host "----------------------------------------------------------------"
8: Foreach ($member in $groupMO.GetRelatedMonitoringObjects())
9: {
10: Write-Host $member.DisplayName "(" $member.GetLeastDerivedNonAbstractMonitoringClass().DisplayName ")"
11: }
12: }
Example output:
----------------------------------------------------------------
Members of group : London
----------------------------------------------------------------
UKSERVER2.corp.local ( Demo Computer )
JalaSW2950 - 10.0.2.253 - V2* ( Cisco switch )
UKSERVER3.corp.local ( Demo Computer )
UKSERVER4.corp.local ( Demo Computer )
UKSERVER1.corp.local ( Demo Computer )
JalaRO2621 - 10.0.2.254 - V2* ( Cisco router )
The source of the script can be downloaded here.
If you have any questions or other ideas about extracting information about Live Maps groups please contact us at support@savision.com
More information about Live Maps can be found here.