{"id":2963,"date":"2012-04-11T10:56:09","date_gmt":"2012-04-11T08:56:09","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=2963"},"modified":"2012-04-11T10:56:09","modified_gmt":"2012-04-11T08:56:09","slug":"building-groups-in-operations-manager-with-a-bit-of-orchestrator-magic","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=2963","title":{"rendered":"Building groups in Operations Manager, with a bit of Orchestrator magic"},"content":{"rendered":"<p>In many scenarios you have a list of servers, a database query result or a place in your Active Directory that contains servers that you want to monitor in some special way. Often you need the machines in a group in Operations Manager so you can for example create overrides, maintenance mode and views for that group. It is a pretty\u00c2\u00a0boring\u00c2\u00a0work to build the group manually and then to keep the group updated.<\/p>\n<p>A way to get the Operations Manager group in sync with the machine list is to use a runbook that creates a management pack including a group based on the list. This set of example runbooks reads a list of machine, creates a management pack with a group that includes the machines. The list of servers could be generated by another runbook or another tool. The last runbook also imports the management pack into Operations Manager.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_01.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2964\" title=\"20120411_GRP_01\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_01-300x66.jpg\" alt=\"\" width=\"300\" height=\"66\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_01-300x66.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_01.jpg 625w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>This first runbook execute the following steps. In general this runbook checks if the machines in the list has a Operations Manager agent, if they are monitored by Operations Manager<\/p>\n<ol>\n<li>Delete File. Deletes old Machines_IDS.txt file if it exists. Machines_IDS.txt is used later in the runbook and needs to be blank before we begin<\/li>\n<li>Get Lines. Read all lines in the list. The list is simple a text file with servers, one server per row<\/li>\n<li>Get Monitor. Check if Operations Manager have a Microsoft.Windows.Computer monitor for the servers in the text file<\/li>\n<li>Append Line. For each machine that has a monitor, we write the machine name to a temporary file. This is the same file as step one deleted any old version of<\/li>\n<li>Junction. We merge multiple threads together<\/li>\n<li>Invoke Runbook. Trigger next runbook<\/li>\n<\/ol>\n<div><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_02.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter  wp-image-2965\" title=\"20120411_GRP_02\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_02-300x36.jpg\" alt=\"\" width=\"300\" height=\"36\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_02-300x36.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_02.jpg 834w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/div>\n<div>The second runbook executes the following steps. In general it builds the management pack file in XML<\/div>\n<div>\n<ol>\n<li>Delete File. Deletes old MP files<\/li>\n<li>Modify Counter. We use a counter to keep track of the management pack version number. This step adds one to that counter value<\/li>\n<li>Get Counter Value. Get the counter value for the same counter as in step 2<\/li>\n<li>Append Line. This steps writes the first half of the XML code that needs to be in the management pack. The GroupInstanceID is a random ID that the Operations Manager console generated when I test created a group in the console. You could replace that and all the other names in the management packs.<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_03.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2969\" title=\"20120411_GRP_03\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_03-300x179.jpg\" alt=\"\" width=\"300\" height=\"179\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_03-300x179.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_03.jpg 616w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Read Line. This step reads every machine that we wrote in the machine list in the first runbook, step 4,<\/li>\n<li>Append Line. This steps writes all the machines from step 5 into the management pack file<br \/>\n<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_04.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2970\" title=\"20120411_GRP_04\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_04-300x130.jpg\" alt=\"\" width=\"300\" height=\"130\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_04-300x130.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_04.jpg 560w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Junction. We merge multiple threads together<\/li>\n<li>Append Line. Writes the end of the management pack, some more XML<\/li>\n<li>Invoke Runbook. Starts the last runbook and pass the path to the management pack file<\/li>\n<\/ol>\n<div>The last runbook inports the management pack file into Operations Manager<\/div>\n<div><\/div>\n<div><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_05.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2971\" title=\"20120411_GRP_05\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_05.jpg\" alt=\"\" width=\"281\" height=\"117\" \/><\/a><\/div>\n<div><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_06.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2972\" title=\"20120411_GRP_06\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_06-300x121.jpg\" alt=\"\" width=\"300\" height=\"121\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_06-300x121.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120411_GRP_06.jpg 605w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/div>\n<div><\/div>\n<\/div>\n<p>The result is that each time you run this set of runbooks they will generate a new management pack version with a group that includes all the machines from your list, that has a agent. The management pack is imported into Operations Manager and you can use the updated group. You could include a step to seal the management pack too.\u00c2\u00a0You can download my runbook example here,\u00c2\u00a0<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2012\/04\/20120410_GroupSync_WOLF.zip\">20120410_GroupSync_WOLF<\/a>.\u00c2\u00a0\u00c2\u00a0Please note that this is provided \u00e2\u20ac\u0153as is\u00e2\u20ac\u009d with no warranties at all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In many scenarios you have a list of servers, a database query result or a place in your Active Directory that contains servers that you want to monitor in some special way. Often you need the machines in a group in Operations Manager so you can for example create overrides, maintenance mode and views for &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=2963\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[61,60,19],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2963"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2963"}],"version-history":[{"count":5,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2963\/revisions"}],"predecessor-version":[{"id":2975,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2963\/revisions\/2975"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2963"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}