How do I create a dynamic group of computers of specific OS and agent version?

Pauciloquent 71 Reputation points
2021-10-22T04:22:12.047+00:00

Hi,

We are in the middle of SCOM 2019 upgrade project and using following Kevin's MP for multi-home.

https://kevinholman.com/2018/06/12/how-to-multihome-a-large-number-of-agents-in-scom/

But we have got a bit tricky situation. We want to multihome only those computers that are Windows Server 2012, 2016 and 2019, and agent version is equal or greater than 10. Now on paper, it doesn't look a challenge, create a dynamic group and override that Kevin's specific rule.

But I don't know why I can't create a dynamic group with above mentioned criteria. Can anyone please share a formula or line of code that I can use in XML if it's not possible via console? I will be highly obliged.

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,413 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AlexZhu-MSFT 5,551 Reputation points Microsoft Vendor
    2021-10-29T07:21:41.61+00:00

    Hi,

    Sorry for missing this thread. I'm afraid that this cannot be done with the existing one. My thoughts is to deploy a script to all the managed Windows agents (via group policy or other management tool, such as configuraion manager) to add the new management group (multi-homed).

    Here's the script for your reference (just illustrate how it works and you may need to modify it to cater for the real environment)

    	$mma1 = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'  
    	  
    	#$computers = import-csv c:\temp\computer_list.csv  
    	  
    	#check if the new management group already exists  
    	$p = $mma1.GetManagementGroup("test01")  
      
      
    	#if it does not exist, then check the criteria and add the new management group if the condition is met.   
    	if ($p -eq $null)  
    	{  
    		$agent_version = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\setup" -ea silentlycontinue).AgentVersion  
    		  
    		#for debugging  
    		$agent_version  
    		[environment]::OSVersion.Version.major  
    		[environment]::OSVersion.Version.major -ge 6 -and $agent_version -like '10.*'  
    		  
    		if ([environment]::OSVersion.Version.major -ge 6 -and $agent_version -like '10.*')  
    		# server 2012/2012r2: 6  
    		# server 2016/2019: 10  
    		{  
    			$mma1.AddManagementGroup('test01' , 'om16.sc.com' , 5723)  
    			write-host "management group test01 was added!"  
    			$mma1.ReloadConfiguration()  
    		}  
    	}  
    	else  
    	{  
    		"test01 already exists!"  
    	}  
    

    before running the script
    144892-scom-management-group-11.png

    script runing
    144893-scom-management-group-12.png

    after running the script
    144933-scom-management-group-13.png

    Alex
    If the response is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments