Ask a questionAsk a question
 

AnswerSNMP via Script

  • Thursday, August 06, 2009 3:36 PMalsoszaa Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Is there a way to have a script configure the SNMP info? More specifically, I need to have a script to configure the service "SNMP Service" and "SNMP Trap". I am running this on multiple versions of Windows 2003 and 2008 (Win 2K3 Standard x64 is the most popular out of these though)

    My ultimate goal is to have the following configured via script:
    1. in SNMP Service the tab named "Traps" I need to add two community names.
    2. Under trap destination I would need it to add two server names for only one of the community names (from #1)
    3. in the "Security" tab, in the "Accepted community names" have both the community names from #1. Then assign "read only" to the first community from #1 and "read write" assigned to the sencond community from #1
    4. Also want the radio button selected "Accept SNMP packets from any host"
    5. In the other SNMP service "SNMP Trap" I would need the service start Automatically instead of manually.

    Is this possible??? I have hundreds of servers that I need to run this script on. This will make configuration very speedy with the click of a button (if possible). However I don't need this script to run on multiple servers at once (unless that is also possible. I just need to run it from each server individually. That's fine.

    Thank you

Answers

All Replies

  • Thursday, August 06, 2009 10:34 PMCuppaT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    Can you not use Group Policy to do the settings for you?  If so, you only need to install SNMP onto the servers, which is possible via script.  I don't have my script to hand, but I can provide it if needs be, but I assure you the easiest way to do the configuration is via Group Policy.
    If shortcuts worked, then they wouldn't be shortcuts would they...
    • Proposed As Answer byCuppaT Friday, August 07, 2009 10:07 AM
    •  
  • Friday, August 07, 2009 2:57 AMTim Quan - MSFTMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

     

    As this issue is related to scripting, I suggest discussing it in our MSDN forum. They mainly deal with scripting issues and should be the best resource to troubleshoot this issue.

     

    MSDN forum:

    http://social.msdn.microsoft.com/forums/en-US/categories/

     

    I hope you issue can be resolved soon.

     

    Tim Quan - MSFT

     

  • Friday, August 07, 2009 10:07 AMCuppaT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer

    Alsoszaa,

    Put the following in a file called 'SNMP.txt'

         [NetOptionalComponents]
         SNMP = 1
     
         [SNMP]
         Accept_CommunityName = public:Read_Only
         Any_Host = Yes
         Community_Name = "public"
         Contact_Name = "Name"
         Limit_Host = 0.0.0.0
         Location = "Location"
         Send_Authentication = Yes
         Service = Applications, Internet, End-to-End, Physical, Datalink
         Traps = 192.168.0.1

    Save that somewhere, say root of C:\
    Then run this command line, it uses the sysocmgr to install SNMP and reads the config settings from the .txt file.

         %windir%\system32\sysocmgr.exe /i:%windir%\inf\sysoc.inf /u:%SYSTEMDRIVE%\SNMP.txt /r

    Hope this helps.


    If shortcuts worked, then they wouldn't be shortcuts would they...
    • Proposed As Answer byCuppaT Friday, August 07, 2009 10:07 AM
    •  
  • Thursday, November 05, 2009 4:26 PMJasonHuff Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm in the same boat, looking for a script to automate this chore.  MSDN forums aren't usually inhabited by sysadmin types looking for fixes, but maybe the Scripting Guys have a few tricks up there sleeves.

    http://technet.microsoft.com/en-us/scriptcenter/default.aspx
  • Thursday, November 05, 2009 4:34 PMJonathan440 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I configured the SNMP the way I wanted it, then exported the setting out of the registry [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters]