Remotely Managing Windows-based SNMP Service using PSTools

Problem Statement:

I have a large quantity of Windows based server and need to update the SNMP security settings on them. A google search will result in lots of complicated scripts or process that have to be completed by hand. I wasn’t satisfied with any of these solutions so I turned to the PSTools from Sysinternals instead. This isn’t intended to be a comprehensive article, it is merely what I have found to be the simpliest approach.

The examples in this article require the psexec and psservice executables. You can download them from the Microsoft website at http://technet.microsoft.com/en-us/sysinternals/default.aspx

If you had Microsoft System Center this process is really easy but I don’t have SCCM at my disposal in this environment.

Windows Server 2008

Installing SNMP Service:

psexec @serverslist.csv  “start ocsetup snmp /quiet /norestart”

Notes: (1) serverlist.csv is a text document with one column which has a server name per row; (2) I don’t have the username and password switches in my command because I ran the command with a user account that has admin rights on the target server.

Configuring SNMP Service:

Either of the following approaches work well:

Import a registry key (reg command works on Win 2003 and 2008):

psexec @serverlist.csv "reg import snmp.reg"

Group Policy:

Windows 2008 Group Policy features give the ability to set registry keys to Windows 2008 servers.

Restarting SNMP Service

I found that after setting the SNMP settings across all of my servers the servers still were not reporting to my NMS. To force the issue I ran the following script to restart the SNMP service on all my servers:

foreach ($line in $serverlist) {.\psservice "\\$($line.hostname)" restart snmp}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s