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.
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:
ii) To run remote sessions on Windows PowerShell 2.0, the local and remote computers must have the following:
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.
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 |
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>