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 set (and change) an NTP time source in Windows Server 2008 R2 (SBS 2011 and Vanilla Server).

Recently, the clocks on my home networked PCs began drifting off sync until the difference was around 30 minutes. At first i thought that my SBS server was no longer synching with time.windows.com (the default time server for windows). After a quick look at the event log, I could see that it was syncing correctly […]

Procurve Switches and Windows Network Load Balancing in Multicast Mode causing high collision and drop rates

Over the last few days we have been looking at getting a Client Access Array going for our Exchange 2010 setup for basic redundancy and load balancing. I thought I would outline an issue we discovered with using Windows Network Load Balancing in a HP switching environment. The first is whether to use Unicast or […]

How to remove the Open File Security Warning Prompt during Driver Deployment or User Login when using MDT or SCCM

During a deployment of Windows or even after Windows is deployed you see an Open File – Security Warning prompt when a .EXE runs (similar to the one below). This happens because when you download an .EXE, .ZIP, or .CAB Internet Explorer (as well as Firefox and Chrome) saves what is called a Zone Identifier, […]