Install SNMP on Windows Server 2012 Via Command Line

This batch script can be run from a single computer and you just type the name of the computer you want SNMP setup on as the argument (e.g.   InstallSNMP.cmd NEWSERVERNAME).  WINRM must be configured on the server that needs SNMP setup, winrm is setup by default on Windows Server 2012 (winrm quickconfig).  On one similar server, setup SNMP as desired then export the entire Parameters key from “HKLM\System\CurrentControlSet\Services\SNMP\Parameters” and save as SNMPConfig.reg file.

"%SystemRoot%\System32\winrs.exe" -remote:%1 dism.exe /online /enable-feature /featurename:"SNMP"

"%SystemRoot%\System32\winrs.exe" -remote:%1 dism.exe /online /enable-feature /featurename:"WMISnmpProvider"

NET USE \\%1\c$

if not exist "\\%1\c$\TEMP" mkdir \\%1\c$\TEMP

REM On one server setup SNMP as desired then Export Entire Parameters key from HKLM\System\CurrentControlSet\Services\SNMP\Parameters and save as SNMPConfig.reg file

XCOPY "\\PATH TO REG FILE SAVED\SNMPConfig.reg" \\%1\c$\TEMP /d /c /y

"%SystemRoot%\System32\winrs.exe" -remote:%1 regedit.exe /s "C:\temp\SNMPConfig.reg"

"%SystemRoot%\System32\winrs.exe" -remote:%1 sc config SNMPTRAP start=auto

"%SystemRoot%\System32\winrs.exe" -remote:%1 NET STOP SNMP

"%SystemRoot%\System32\winrs.exe" -remote:%1 NET STOP SNMPTRAP

"%SystemRoot%\System32\winrs.exe" -remote:%1 NET START SNMP

"%SystemRoot%\System32\winrs.exe" -remote:%1 NET START SNMPTRAP

NET USE \\%1\c$ /delete /y

services.msc /Computer:%1

Example Usage:

Open Command line on any machine and navigate to where the scripts are saved (Fix path to SNMPConfig.reg file in the script):

 

c:
cd temp
remoteinstallsnmp.cmd WindowsServerName

Resources:
http://social.technet.microsoft.com/wiki/contents/articles/4032.how-to-install-snmp-remotely.aspx

One thought on “Install SNMP on Windows Server 2012 Via Command Line

  1. Pingback: SNMP Service Setup and SNMP Trap Setup | Question Driven

Leave a Reply

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

%d bloggers like this: