Blog

June 11 2009 3:17 PM

As explained in part 3 of the SNMP in OpsMgr / Essentials series (still in progress), we explained that SNMP-enabled devices can be monitored from any management server OR agent-managed computer. The question we answer today is:

"How do I change the proxy agent for some or all of my network enabled devices?"

If I want to use an agent-managed computer as the proxy for multiple network devices, the script below will allow you to submit a wildcard filter based on device IP address to update the proxy agent for all SNMP-enabled devices matching the filter. Check back for the next installment in which we demonstrate how to specify a management server as the proxy agent for multiple devices.

INSTRUCTIONS FOR USE

Cut-and-paste the script below into Notepad, and save as updateproxyagent.ps1. Script should run from any computer with OpsMgr Console and Powershell installed.

SYNTAX

The script accepts the following 3 required parameters. Run with no parameters to view syntax help.

-rootMS: FQDN of the root management server for the target management group.

Ex: 'RootManagementServer.fqdn.local'

-proxyAgent: Agent that will serve as the proxy agent

Ex: ‘dc.contoso.com'

-deviceName: IP address or IP wildcard range.

Ex: ‘192.168.1*’

SAMPLE SCRIPT

Here is the sample script. You should be able to cut-and-paste this one with no worries about line wrap.

#-----------Begin Sample Script--------------

param($rootMS,$proxyAgent, $deviceName)

#Echo syntax if -rootMS parameter is NULL
     if ($rootMS -eq $null) {

        Write-Host ""
        Write-Host "-rootMS: FQDN of the root management server for the target management group.";
        Write-Host "Ex: RootManagementServer.fqdn.local";
        Write-Host ""
        Write-Host "-proxyAgent: Agent-managed computer that will serve as the proxy agent";
        Write-Host "Ex: ‘dc.contoso.com";
        Write-Host ""
        Write-Host "-deviceName: IP address or IP wildcard range.”;
        Write-Host "Ex: ‘192.168.1*’”;
        Write-Host ""
 exit;
     }

#connect to mgmt group
$ServerName=$rootMS
add-pssnapin  Microsoft.EnterpriseManagement.OperationsManager.Client ;
set-location  OperationsManagerMonitoring:: ;
new-managementGroupConnection -ConnectionString:$serverName;
set-location $ServerName;

#Retrieve all our monitored network devices
$netDevices = get-remotelymanageddevice | where-object {$_.Name -like $deviceName}

#Retrieve agent that will serve as proxy agent
$proxy = get-agent | Where-Object {$_.PrincipalName -like $proxyAgent }

#Sets the proxy of all network devices to the specified proxy server
Set-ProxyAgent -ProxyAgent $proxy -Device $netDevices 

#-----------End Sample Script--------------

Conclusion

Hopefully some of you will find this one useful. Check back soon when we'll look at how to assign a management server as a proxy agent for multiple SNMP-enabled devices using Powershell. Please submit feedback as a comment on this post.


 Print  

Quick Links
Top Contributors
Pete Zerger
Points: 25205
Level: System Center Expert
Simon Skinner
Points: 20303
Level: System Center Expert
Tommy Gunn
Points: 19054
Level: System Center Expert
MadHatter
Points: 11573
Level: System Center Expert
Stefan Koell
Points: 10134
Level: System Center Expert