Monday, February 8, 2010

Automating "Proxying Enabled" for Cluster Nodes

If you perform a "mass installation" of OpsMgr, the task of turning agent proxying on is quite a mission. The way I see it is as follows: most people use clusters for SQL redundancy, meaning that it is pretty safe to assume that every object contained in the Microsoft.Windows.Cluster.Service class will need to have agent proxying enabled for this to actually work.

If we use this Powershell code, we can loop through all objects contained within the Cluster class and enable it in one step.


$rootMS = "RMS1"
$targetClass = "Microsoft.Windows.Cluster.Service";
Set-Location OperationsManagerMonitoring::
New-ManagementGroupConnection $rootMS
Set-Location $rootMS
$matches = Get-MonitoringClass -name $targetClass | Get-MonitoringObject | Select-Object
Foreach($object in $matches) {
[string]$currentAgent = $object.Path
$agent = Get-Agent | Where-Object {$_.Name -eq $currentAgent}
if($agent.proxyingEnabled -eq 'False')
Write-Host "$currentAgent doesn't have proxying enabled yet, enabling now"
$agent.proxyingEnabled = $true;
Write-Host "Proxying already enabled for $currentAgent, skipping..."

Easy peasy.

No comments:

Post a Comment