Enable SNMP for PRTG with PowerShell

, , ,

An MSP I do some consulting for use PRTG for their monitoring of environments. SNMP is a lightweight monitoring method for PRTG which trumps WMI monitoring. and doesn’t require admin rights on the local machine (or the shortcut of using a domain admin account). I’ve got a quick PowerShell script that will install the SNMP service in Windows and then configure the Community Name/String and IP Address for the server to be allowed. Simply load the script and change the variables at the top.

$CommunityManagers = '10.220.3.25'
$CommunityString = 'MySuperSecretSNMPCommunity'

You can then run the script which will install the SNMP service and configure it with the above values.

# Import the ServerManger Module
Import-Module ServerManager

# Variables
$CommunityManagers = '10.220.3.25'
$CommunityString = 'MySuperSecretSNMPCommunity'
 
# Check if the SNMP Service is already installed, if not then install it
$check = Get-WindowsFeature | Where-Object {$_.Name -eq 'SNMP-Services'}
If ($check.Installed -ne 'True') {
    #Install/Enable SNMP Services
    Add-WindowsFeature SNMP-Services | Out-Null
}
 
# Verify Windows SNMP Servcie is enabled
If ($check.Installed -eq 'True'){
    # Set the configured SNMP Manager(s)
    reg add 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers' /v 1 /t REG_SZ /d localhost /f | Out-Null
    # Used as counter for incremting permitted managers
    $i = 2
    Foreach ($CommunityManagers in $CommunityManagers){
        reg add 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers'; /v $i /t REG_SZ /d $CommunityManagers /f | Out-Null
        $i++
        }
    # Set the SNMP Community String(s) as read only
    Foreach ( $string in $CommunityString){
        reg add 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities'; /v $string /t REG_DWORD /d 4 /f | Out-Null
        }
}

PRTG was and still is a great monitoring tool, however I know a number of users are starting to look else where due to their price increases.


Leave a Reply

More Posts

How to Configure SNTP/NTP Time Source on HP ProCurve MSM 765zl Wireless Mobility Controller

I was recently investigating authentication methods for our Wireless system and wanted to test out Active Directory.  Basically, the controller would be checking directly with Active Directory if clients should be allowed to access our Wireless network.  After we started configuring Active Directory Authentication we noticed that the time on our MSM controller was off, […]

ScreenConnect Router Service Setup

Despite all the things people say about Connectwise, I still hold ScreenConnect or Connectwise Control close to my heart as one of the best support and remote access tools out there. It’s light, friendly and easy to use for support staff and end users and just gets the job done. I look after our own […]

Fixing Windows cannot connect to printer with Error Error 0x0000007e when shared on Windows Server 2003 or 2008 32 bit (x86) and your client is 64 bit

So I was out installing a new laptop for a client recently, their server infrastructure is very old (they’re still running Server 2003 but about to migrate) and doing the final stage of the deployment I was installing the local printer in the office but got Windows cannot Connect to the Printer (0x0000007e) error every […]