{"id":3614,"date":"2012-04-11T15:34:05","date_gmt":"2012-04-11T13:34:05","guid":{"rendered":"https:\/\/ingmarverheij.com\/?p=3614"},"modified":"2012-04-13T10:10:29","modified_gmt":"2012-04-13T08:10:29","slug":"opsmgr-enable-agent-proxy-via-management-pack","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/opsmgr-enable-agent-proxy-via-management-pack\/","title":{"rendered":"OpsMgr: Enable Agent Proxy via Management Pack"},"content":{"rendered":"\n<p>System Center Operations Manager (SCOM) agents are by default allowed to only return data from the same source. If the agent needs to submit data from another source, for instance in a cluster, the security feature \u2018Agent Proxy\u2019 needs to be enabled. By default this feature is disabled.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Agent-properties-Security.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Agent-properties-Security_thumb.png\" width=\"304\" height=\"111\" \/><\/a><\/p>\n<p>If you create (or import) a management pack that relies on this feature, for example when the management pack submits data from another source, you might want automate this. <\/p>\n<h6><\/h6>\n<p><!--more--><\/p>\n<h6>Automate setting \u201cAllow this agent to act as a proxy and discover managed object on other computers\u201d<\/h6>\n<p>The process of enabling the \u201cAgent Proxy\u201d security feature can be done using a <a href=\"https:\/\/blogs.technet.com\/b\/kevinholman\/archive\/2010\/11\/09\/how-to-set-agent-proxy-enabled-for-all-agents.aspx?Redirected=true\" target=\"_blank\">PowerShell<\/a> script or an executable called <a href=\"https:\/\/blogs.technet.com\/b\/markmanty\/archive\/2012\/02\/02\/automate-setting-allow-agent-to-act-as-proxy-on-scom-agents.aspx\" target=\"_blank\">SetAgentProxyEnabled<\/a>. Although this automates the process of enabling the security feature it still requires an admin to execute the script or process manually.<\/p>\n<h6>&#160;<\/h6>\n<h6>Integrate in Management Pack<\/h6>\n<p>What if you write a management pack that discovers objects from another source (and therefore require the \u201cAgent Proxy\u201d feature)? You might want to set the feature for the admin on the agents where your management pack is active. <\/p>\n<p>To achieve this we\u2019re going to create a rule that runs on the root management server (RMS),<\/p>\n<ul>\n<li>Open the System Center Operations Manager 2007 R2 Authoring Console <\/li>\n<li>Open your management pack \/ create a new management pack <\/li>\n<li>Go to Health Model <\/li>\n<li>Select Rules <\/li>\n<\/ul>\n<h6>&#160;<\/h6>\n<h6>In the Rules view<\/h6>\n<ul>\n<li>Create a new custom rule <\/li>\n<li>Choose an ID (for instance Demo.ManagementPack.Rule) <\/li>\n<\/ul>\n<h6>&#160;<\/h6>\n<h6>On the <strong>General<\/strong> tab<\/h6>\n<ul>\n<li>Give a descriptive name (for \u201cinstance Enable Agent Proxy on my agent\u201d) <\/li>\n<li>Select the target \u2018Microsoft.SystemCenter.RootManagementServer\u2019 <\/li>\n<\/ul>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Management-Pack-Class-Chooser.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Management-Pack-Class-Chooser_thumb.png\" width=\"154\" height=\"131\" \/><\/a><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Demo.ManagementPack.Rule-General.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Demo.ManagementPack.Rule-General_thumb.png\" width=\"154\" height=\"152\" \/><\/a><\/p>\n<p>&#160;<\/p>\n<h6>On the <strong>Modules<\/strong> tab<\/h6>\n<ul>\n<li>Create a new Data Source with type \u2018System.Scheduler\u2019 and Module ID \u2018Scheduler\u2019 <\/li>\n<li>Edit the new created data source \u2018Scheduler\u2019\n<ul>\n<li>Click on Configure <\/li>\n<li>Set the period to 1 \u2013 Hours <\/li>\n<li><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Choose-module-type-Data-Source.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Choose-module-type-Data-Source_thumb.png\" width=\"79\" height=\"67\" \/><\/a><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/System.Scheduler-Configuration.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/System.Scheduler-Configuration_thumb.png\" width=\"79\" height=\"79\" \/><\/a><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Configuration-Schedule.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Configuration-Schedule_thumb.png\" width=\"79\" height=\"73\" \/><\/a> <\/li>\n<\/ul>\n<\/li>\n<li>Create a new Action with type \u2018Microsoft.Windows.PowerShellAction\u2019 and Module ID \u2018ExecuteScript\u2019 <\/li>\n<li>Edit the new created Action \u2018ExecuteScript\u2019\n<ul>\n<li>ScriptName : ClassProxyEnabler.ps1 <\/li>\n<li>ScriptBody (see below) <\/li>\n<li>TimeoutSeconds: 60 <\/li>\n<li><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Choose-module-type-Action.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Choose-module-type-Action_thumb.png\" width=\"79\" height=\"67\" \/><\/a><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/ExecuteScript-Configuration.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/ExecuteScript-Configuration_thumb.png\" width=\"79\" height=\"79\" \/><\/a> <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Demo.ManagementPack.Rule-Modules.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"\" border=\"0\" alt=\"\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2012\/04\/Demo.ManagementPack.Rule-Modules_thumb.png\" width=\"154\" height=\"152\" \/><\/a><\/p>\n<p>&#160;<\/p>\n<h6>Last step<\/h6>\n<p>Now save the management pack and import the management pack into the Management Group.<\/p>\n<p>The PowerShell script (based on the script from <a href=\"https:\/\/blogs.technet.com\/b\/operationsmgr\/archive\/2009\/09\/29\/enabling-agent-proxy-for-a-class-in-system-center-operations-manager-2007.aspx\" target=\"_blank\">Jonathan Almquist<\/a>, stripped down the logging and&#160; parameters ) to set the \u201cAgent Proxy\u201d security feature.<\/p>\n<p>DO NOT FORGET to change the $ClassName to the class object that target\u2019s your class.<\/p>\n<pre lang=\"powershell\">##--Add SCOM snapin\nAdd-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client\n\n##--Connect to SCOM\nNew-ManagementGroupConnection -ConnectionString:localhost\nSet-Location \u2018OperationsManagerMonitoring::\u2019\n\n##--Set constants\n$bTF = $true\n$className = &quot;Microsoft.Windows.Cluster.Node\u201d\n\n##--Get the class in which you want to set Agent Proxing \n$class = Get-MonitoringClass | Where {$_.Name -eq $className } \n\n##--Get all objects in that class \n$objects = Get-MonitoringObject -monitoringClass:$class \n\n##--Create an array of BME's \n$arrBME = @() \nForeach ($object in $objects) \n    { \n    If ($object.FullName -notcontains &quot;Microsoft.Windows.Computer:&quot;) \n        { \n        Do \n            { \n            $parent = $object.getParentPartialMonitoringObjects() \n            Foreach ($oParent in $parent) {If ($oParent.FullName -match &quot;Microsoft.Windows.Computer&quot;) {$object = $oParent}} \n            } \n        Until ($object.FullName -match &quot;Microsoft.Windows.Computer&quot;) \n        $arrBME += $object.Id.ToString() \n        } \n    } \n\n##--Create an array of agents to help script performance. \n$agentArray = @() \nForeach ($agent in Get-Agent) \n    { \n    $agentArray += $agent \n    } \n\n##--Walk through the array and set Agent Proxying for each agent \nForeach ($BME in $arrBME) \n    { \n    $i=0 \n    While ($i -ne $agentArray.count) \n        { \n        If ($BME -eq $agentArray[$i].Id.ToString()) \n            { \n            ##--If already set to preference, skip with message. \n            If ($agentArray[$i].ProxyingEnabled.Value -ne $bTF) \n                { \n                $agentArray[$i].set_proxyingEnabled($bTF) \n                $agentArray[$i].applyChanges() \n                $i = $agentArray.count \n                } \n            Else \n                { \n                $i = $agentArray.count \n                } \n                \n            } \n        Else \n            { \n            $i+=1 \n        } \n    } \n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>System Center Operations Manager (SCOM) agents are by default allowed to only return data from the same source. If the agent needs to submit data from another source, for instance in a cluster, the security feature \u2018Agent Proxy\u2019 needs to be enabled. By default this feature is disabled. If you create (or import) a management [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[311],"tags":[431,672,442,235],"class_list":["post-3614","post","type-post","status-publish","format-standard","hentry","category-system-center-operations-manager-scom","tag-opsmgr","tag-powershell","tag-proxy","tag-scom"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=3614"}],"version-history":[{"count":2,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3614\/revisions"}],"predecessor-version":[{"id":3644,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/3614\/revisions\/3644"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=3614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=3614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=3614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}