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

Get the last Reboot or Shutdown reason and user from the Windows Event Log

Start by going into Event Viewer (Windows+R or the Start Menu and type eventvwr.msc).  Navigate to the System Log under Windows, we then want to use Filter Current Log to allow us to only show Events with certain attributes (such as Source or IDs). In our case, we want to filter on Event Source: USER32.  […]

Australian FTTP via Telstra not connecting to FortiGate

We recently had a customer take advantage of a free upgrade from FTTN (Fibre to the Node) to FTTP (Fibre to the Premise) for their NBN (National Broadband Network) service. However during cut-over the FortiGate wasn’t picking up connectivity on the WAN port, this had the on-site guy stumped for 10 minutes until we jumped […]