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.