You can although add the specific values to the registry manually or using the following powershell-script. The script is based on the work of Sander Stad and is slightly modified to work with Powershell 3.0 but only on localhost:
# PowerShell script to edit the SNMP registry
#
# Author: Sander Stad
# Version: 1.0 June 2011 tested on Powershell v2.0
# Version: 1.1 April 2013 tested on Powershell v3.0, working on localhost only!
# Usage: <script-path and name> -Manager '10.0.0.1, 10.0.0.2' -Community 'public, test'
Param(
[string] $Manager, # List of managers to add, a manager is the host who has access to snmp on this machine
[string] $Community # List of communties to add
)
$Server='localhost'
$serviceCheck = Get-WmiObject -computer $Server Win32_Service -Filter "Name='SNMP'" -ErrorAction SilentlyContinue
# Check if the SNMP Service is installed
if($serviceCheck.Name -eq 'SNMP')
{
# Create the registry object
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Server)
$regKeyMan = $reg.OpenSubKey('SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers', $true)
$regKeyCom = $reg.OpenSubKey('SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities', $true)
# Get the amount of managers and communities already present
$managerCount = $regKeyMan.ValueCount
$communityCount = $regKeyCom.ValueCount
$managerArray = @()
$communityArray = @()
# Get all the present values and save them in the array
for($i = 1; $i -le $managerCount; $i++)
{
$managerArray += $regKeyMan.GetValue($i)
}
for($i = 0; $i -le $communityCount; $i++)
{
$communityArray += $regKeyCom.GetValue($i)
}
# Increase counters
$managerCount++
write-host $communityArray
#Check if the localhost can query the SNMP service.
if(($managerArray -contains 'localhost') -eq $false)
{
Write-Host -foregroundcolor Blue " - Adding manager key: localhost"
$regKeyMan.SetValue($managerCount, 'localhost')
$managerCount++
}
# Run through each of the managers and check the registry if the entry
# already exists.
$Manager.split(',') | foreach {
$m=$_.Trim()
if(($managerArray -contains $m) -eq $false)
{
Write-Host -foregroundcolor Blue " - Adding manager key: $m"
# Add the manager if it doesn't exist
$regKeyMan.SetValue($managerCount, $m, [Microsoft.Win32.RegistryValueKind]::String)
#Increase the manager counter
$managerCount++
}
}
# Run through each of the communities and check the registry if the entry
# already exists.
$Community.split(',') | foreach {
$c=$_.Trim()
if(($communityArray -contains $c) -eq $false)
{
Write-Host -foregroundcolor Blue " - Adding community key: $c"
# Add the community if it doesn't exist
$regKeyCom.SetValue($c, 4, [Microsoft.Win32.RegistryValueKind]::DWord)
# Increase the community counter
}
}
}
else
{
write-host -foregroundcolor Red "SNMP Service not present!"
}
Write-host -foregroundcolor Green “Completed”
Add comment