Powershell: Updating Proxy Agent for Multiple SNMP-enabled Devices (part 2)

In part 1, we demonstrated how to update the proxy agent for a group of managed SNMP-enabled devices. The difficulty in using the solution presented is part 1 is in using the get-agent cmdlet to retrieve the potential proxy agent to pass to set-proxyagent, which only returns agents; no management servers are presented. Using the get-managementserver cmdlet in it’s place results in a failure because it does not return the right object to pass to set-proxyagent.

If I want to use a management server 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, and assign a managment server as the proxy agent. Thanks to Marco Shaw for a critical assist in working out the code to allow passing wildcard for the -deviceName parameter.


Cut-and-paste the script below into Notepad, and save as updateproxyagentMS.ps1. Script should run from any computer with OpsMgr Console and Powershell installed.This script will load the OpsMgr Powershell snap-in and connect to your Management Group.


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: Management Server that will serve as the proxy agent Ex: ‘ms1.contoso.com’

-deviceName: IP address or IP wildcard range.

Ex: ‘192.168.1*’


Here is the sample script. You should be able to cut-and-paste this one with no worries about line wrap. #———–Begin Sample Script————–

#———–End Sample Script————–


Hope you find this one useful. Please submit feedback as a comment on this post.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.