Blog
By Pete Zerger on 6/11/2009 3:22:24 PM • Rank (1589) • Views 2101
0

0

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.

Map Location


GPS Latitude: 0.00000 Longitude: 0.00000
Comments (2) - Comment RSS
Kris Bash wrote: on Jun 11, 2010 02:32 PM
This is fantastic, by the way. Thanks for providing the workaround to assigning remote devices to management server proxy agents.
Marnix Wolf wrote: on Oct 04, 2011 04:09 AM
Great stuff Pete! You're one of the SCOM Kings to me! Thanks for sharing since this saved me hours of boring and prone to error, work!
Cheers,
Marnix


Who Viewed
Who Reviewed
Categories
Related Pages
Shortened URL
http://tinyurl.com/ylcp6x3

Top Contributors
Featured Members
Pete Zerger
Points: 65442
Level: System Center Expert
Tommy Gunn
Points: 42712
Level: System Center Expert
Simon Skinner
Points: 40744
Level: System Center Expert
Stefan Koell
Points: 28999
Level: System Center Expert
Andreas Zuckerhut
Points: 27434
Level: System Center Expert