Kevin Holman's System Center Blog

Posts in this blog are provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified in the Terms of UseAre you interested in having a dedicated engineer that will be your Mic

How to set Agent proxy enabled for all agents

How to set Agent proxy enabled for all agents

  • Comments 10
  • Likes

Some customers have decided it is too much trouble to mess with setting Agent Proxy enabled on agents on an as-needed basis.  In some cases, they have too many agents being added on a daily basis, and the amount of work to keep up with this setting is cumbersome. 

We previously discussed some tools to enable these in bulk.  However, ongoing newly installed agents pose a bit of a challenge.  http://blogs.technet.com/b/kevinholman/archive/2007/11/13/bulk-enable-of-agent-proxy-setting.aspx

 

We already must enable agent proxy for the following roles, and more:

  • Domain Controller
  • Cluster Node
  • Exchange Server
  • SharePoint
  • SMS
  • Many 3rd party MP’s
  • Watcher Nodes
  • Any custom MP’s where the agent sends information about another entity.

 

Some customers just prefer to enable agent proxy on all agents, on a schedule, so they don’t have to worry with this, especially since it is already enabled on our most critical servers in the environments… domain controllers, exchange servers, and clusters.

Here is a powershell script which does just this.  It can be scheduled to run once per day, and take care of this setting for any agents that do not have agent proxying enabled.

param($RMS)
## prepare OpsMgr shell 
if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null) 
{ 
   Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorAction SilentlyContinue -ErrorVariable Err 
   if ($Err) { $(throw write-Host $Err) } 
} 
if ((Get-ManagementGroupConnection | Where-Object {$_.ManagementServerName -eq $RMS}) -eq $null) 
{    
   New-ManagementGroupConnection $RMS -ErrorAction SilentlyContinue -ErrorVariable Err 
   if ($Err) { $(throw write-Host $Err) } 
} 
if ((Get-PSDrive | Where-Object {$_.Name -eq 'Monitoring'}) -eq $null) 
{ 
   New-PSDrive -Name: Monitoring -PSProvider: OperationsManagerMonitoring -Root: \ -ErrorAction SilentlyContinue -ErrorVariable Err 
   if ($Err) { $(throw write-Host $Err) } 
} 
Set-Location Monitoring:\$RMS

## connect to management group 
$ManagementGroup = New-Object Microsoft.EnterpriseManagement.ManagementGroup($RMS) 
$ManagementGroup.Reconnect()

## set proxy enabled for all agents where it is disabled
$NoProxy = get-agent | where {$_.ProxyingEnabled -match "False"}
$NoProxy|foreach {$_.ProxyingEnabled=$true}
$NoProxy|foreach {$_.ApplyChanges()}

 

It takes a single parameter – the RMS name where you want to enable proxy for all agents.  It loads the OpsMgr snap-ins if they aren't already loaded, and then runs the simple get-agent command at the end of the script.

A sample txt file is also attached.

Attachment: setproxyenabled.txt
Comments
  • There is also a GLOBAL Setting for the whole management Group (like there was in MOM2005) but it is not exposed in the UI.

    Set-DefaultSetting -Name HealthService\ProxyingEnabled -Value True

    Once you do this, ALL agents should automatically inerit it and you won't have to do it again.

    I don't think it is supported, and I have not personally done TESTING with it, but it should work.

  • Both worked for me, Great thanks.

  • Would this script or "Set-DefaultSetting" enable ONLY the DC's Exchange and Clusters?  Or both of these would enable all the agents to proxy enabled?

  • @Sam - both of these examples will enable agent proxy for ALL agents.

    If you would like to enable agent proxy based on class roles - please see:  

    blogs.technet.com/.../enable-agent-proxy-for-a-class-classproxyenabler.aspx

  • I don't see the Set-DefaultSetting in the list of command in the SCOM2012 shell.  Is there another module that needs to be loaded for this to work?  Or was this command changed or removed in 2012?

  • In OM12 you still load the snap-in to get to set-defaultsetting... From regular powershell run:

    add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";

    new-managementGroupConnection -ConnectionString:ServerName.Domain.dom;

    set-location "OperationsManagerMonitoring::";

    Set-DefaultSetting -Name HealthService\ProxyingEnabled -Value True

  • Thank you so much! Your blog has been such a lifesaver.

  • Thanks you John Erskine. Worked a treat

  • Should I replace RMS with My RMS server name -if yes which part please specify

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
Search Blogs