How to enable SNMP on Windows servers? 

The simple network monitoring protocol (SNMP) is one of the most widely used protocols in the networking world. It is used to monitor a wide range of devices like routers, switches, desktops, servers, domain controllers, etc. But, before you can monitor the devices in your network using SNMP, you need to enable the SNMP service. This is a relatively simple process that can be done with the help of a vendor provided user-manual. 
 
Likewise, enabling SNMP on Windows servers is also a simple task. But, what if you have to enable it on multiple Windows servers in a network that is distributed across domains and datacenters? That can be tedious and time-consuming. To make this easier, we have developed a script using Microsoft's PowerShell framework to remotely enable SNMP on Windows devices that run on Windows Server 2008, 2008 R2, 2012, 2012 R2 and 2016. Now, you can instanly discover and monitor your Windows servers using SNMP in OpManager.  
 
Tip: 
Wondering why you should monitor Windows devices using SNMP?
Monitoring Windows servers using SNMP comes with a host of benefits that include a more efficient use of the CPU, random access memory (RAM) and bandwidth resources, and also requires lesser number of ports for polling devices, unlike WMI."

Steps to enable SNMP on Windows devices 

Step 1: Download the SNMPEnabler.ps1 script.

Step 2: Open the Windows PowerShell utility as an administrator.

Step 3: Run the SNMPEnabler.ps1 script and provide the required input parameters.

Step 4: Now, execute the script with the provided inputs and it will automatically enable and configure SNMP on your local/ remote devices. 

Note:

1. Please confirm if the prerequisites for remote execution are satisfied.

2. Ensure that the host and client devices are available on the same network domain. For multiple domains, you can use a remote device in that domain to execute the script on other Windows machines within that domain.

3. Enable PSRemoting on remote devices in which this script will be executed. This can be done with a Remote Desktop connection.

 

Prerequisites for remote execution 

To create remote sessions and run remote commands the local and remote machine must meet below requirements.

System requirements:

These are the system requirements for script execution on remote machines.

i) To run remote sessions on Windows PowerShell 3.0, the local and remote computers must have the following: 

  • Windows PowerShell 3.0 or later
  • The Microsoft .NET Framework 4 or later
  • Windows Remote Management 3.0

ii) To run remote sessions on Windows PowerShell 2.0, the local and remote computers must have the following:

  • Windows PowerShell 2.0 or later
  • The Microsoft .NET Framework 2.0 or later
  • Windows Remote Management 2.0

User permissions:

By default, the current user must be a member of the administrators group on the remote computer (or) provide the credentials of an administrator.  

Windows network/ firewall permission:

The firewall should not block the remote connection from both server and client side.

Run as administrator:

Administrator privileges are required to enable and configure SNMP.     

 

Input parameters for script execution

The script can process the following inputs parameters. 
 
Sl.No Input parameter Usage Default values Mandatory/ Optional Example
1 h Host name in which the SNMP service needs to be enabled. - Mandatory (if -f not given) -h raj-3515
2 f Path of the file which contains multiple hosts. 

File format :(XXXXX.txt)
opm-dev1
localhost
192.21.23.1
raj-3515.zohocorpin.com
- Mandatory (if -h not given) -f D:\SNMP\hostlist.txt
3 username Username of the account which is used for remote access - Mandatory for remote machines
Optional for the local host
-username workgroup\administrator
4 pass Password of the account which is used for remote access - Optional for the local host

Remote: It can be provided as an argument/ 
you'll be requested for the password during remote execution.
-pass password@123
5 onlyConfigure Used to Configure the SNMP settings on already SNMP enabled machines. 
Possible values true/false. 
If its true then script will only go for configuration.
false Optional -onlyConfigure true
6 communityName The name in which the community will be added in SNMP. public Optional -communityName opmcomunity
7 snmpType Permission to be added from community string. 
Allowed integer values.
'1' -NONE 
'2' -NOTIFY
'4' -READONLY
'8' -READWRITE
'16' -READCREATE.
4 Optional -snmpType 4
8 permittedHost The host which need SNMP access from the Remote machine. default localhost machine Name from which the script has been executed. Optional -permittedHost opm-dev7
9 debug Used for debugging purpose. Possible values true/false. false Optional -debug true
 
  

Script commands and usage

1. Host Specific Enabling

Options to enable and configure a single host with default/ custom options. 

Commands:

1.1. To enable and configure (with default options) SNMP in a local machine

Execute:   .\SNMPEnabler.ps1 -h localhost 

1.2. To enable and configure (with default options) SNMP in a remote machine

Execute:   .\SNMPEnabler.ps1 -h <Remote_MachineName> -username <username>

1.3. To enable and configure (with custom input options) SNMP in a local machine

Execute:  .\SNMPEnabler.ps1 -h localhost -communityName <communityName> -snmpType <snmpType> -permittedHost <permittedHost>

1.4. To enable and configure (with custom input options) SNMP in a remote machine

Execute:   .\SNMPEnabler.ps1 -h <Remote_MachineName> -username <username> -communityName <communityName> -snmpType <snmpType> -permittedHost <permittedHost>

1.5. To configure the community and permitted hosts on an SNMP enabled local machine

Execute:   .\SNMPEnabler.ps1 -h localhost -onlyConfigure true -communityName <communityName> -snmpType <snmpType> -permittedHost <permittedHost>

1.6. To configure the community and permitted host on an SNMP enabled remote machine

Execute:  .\SNMPEnabler.ps1 -h <Remote_MachineName> -username <username> -pass <password> -onlyConfigure true -communityName <communityName> -snmpType <snmpType> -permittedHost <permittedHost>

 

2. Bulk Enabling (using input file containing hosts)

By passing the file path which contains a list of hosts, we can enable and configure SNMP for multiple servers.      

Commands:

2.1. To enable and configure (with default options) SNMP in multiple local/ remote machines

Execute:    .\SNMPEnabler.ps1 -f <filepath> -username <username>

2.2. To enable and configure (with custom options) SNMP in multiple local/ remote machines

Execute:    .\SNMPEnabler.ps1 -f <filepath> -username <username> -communityName <communityName> -snmpType <snmpType> -permittedHost <permittedHost> 

2.3. To configure with community and permitted host on SNMP enabled local/ remote machines

Execute:    .\SNMPEnabler.ps1 -f <filepath> -username <username> -onlyConfigure true -communityName <communityName> -snmpType <snmpType> -permittedHost <permittedHost>

 
Click here to learn more about OpManager, and it's server monitoring capabilities. To know more on how to install and configure SNMP, visit the following links. 
 

 

 

 
 Pricing  Get Quote