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

Backup MySQL Databases running on a Windows Server using Systems Center Data Protection Manager (DPM) 2012.

Running MySQL on a Windows machine is pretty straight forward.  One of the down sides though is that MySQL is not VSS aware and may mis-behave when back up software such as Data Protection Manager or ShadowProtect.  Data Protection Manager (DPM) has the ability (basically called Pre-Backup and Post-Backup Scripts) to perform actions before and after […]

Using PowerShell to Manage Windows Server DNS entries

Firstly, Happy new year. Anyway, I was recently tasked with creating a large number of DNS entries on our internal DNS servers. To accomplish this I decided to use PowerShell to perform an import of a CSV file that I had been given that already had my DNS entries. There was a header row with […]

Setting the default wallpaper on a Windows 10 image deployment through MDT

So recently I’ve been working on improving and streamlining our imaging process. One of the pain points that I have had with Windows 10 was an easy way of setting the default wallpaper, but without locking out the user, i.e. Group Policy from changing it in the future. After a long session of Google Fu […]