Configure SNMP with Powershell

Standard

Powershell can do a lot of stuff and with the right libraries you can do about anything.

I had to configure the SNMP service on a bunch of servers and I wasn’t going to do this by hand for over 80 servers.

It uses three parameters for configuring the service.

ServerList
Path to file that contains all the servers. The text file must have only one server per row.

Manager
The managers that need to be added to the SNMP service. This can be a comma seperated string with  the following format:

Community
This parameter works the same as the Manager-parameter with the same format.

The code

 

 

7 thoughts on “Configure SNMP with Powershell

  1. Bob

    Hi, I need to enable snmp across 40servers running SERVER 2012

    cant get your code to run – any suggestions?
    Error is cannot find servers txt file
    great if you could help

    • Sander Stad

      You have to be a little more specific.
      The code is designed to take arguments like this:
      SNMPConfig -ServerList ‘c:\servers.txt’ -Manager ‘10.0.0.1, 10.0.0.2’ -Community ‘com1, com2’

      If the error says the file can’t be found than there the file isn’t there of you have some privilege issues that the script can’t read or find the file.

      If you still have some issues pleasy supply as much information about your issue as possible.

  2. Per

    Hi,

    I’m new to PS so please bare with me if I’m totally wrong.
    When I tried your script providing the -ServerList as a .txt file as you suggest I get an error saying “Server C:\temp\snmp\Servers.txt could not be reached!”
    But if I instead of calling the .txt writes my server IP directly in the call it’s working.
    I can’t see in your code that you are opening the .txt file so made me wonder.

    Anyhow, thanks for posting this amazing script! 🙂
    Per

  3. Per

    Hi again,

    I see that for multiple values to add e.g. Managers ‘10.0.0.1, 10.0.0.2’ there will be one entry containing both ip’s. Wouldn’t you want a separate entry for each address? Somehow I need to split the comma delimited string into single addresses and add each after that right?

    Cheers,
    Per

  4. Eva

    Hi, this is a handy script and the best I’ve seen to do this task yet. However is there a way to do this for Windows 2003 servers?

    In a mixed environment it would be great to be able to run a single script that will check the OS and then run the proper portion of the script to enable and configure snmp based on the OS version.

Leave a Reply