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.
|
|
|
|
Thank you for your rating!
|
Share This |
Views: 241 :: Rank: (88) |
Filed In: Blog, Operations Manager, Powershell |
242 days ago |
|
|
|
|
|
|
|
|