Skip to content

Instantly share code, notes, and snippets.

@hunzo
Last active June 18, 2025 03:44
Show Gist options
  • Save hunzo/a158a1ccba748ade259f9a29c50ff847 to your computer and use it in GitHub Desktop.
Save hunzo/a158a1ccba748ade259f9a29c50ff847 to your computer and use it in GitHub Desktop.
enable-snmp by powershell script
# Install SNMP Feature
Install-WindowsFeature SNMP-Service -IncludeAllSubFeature -IncludeManagementTools
# Setting SNMP Service Start Automatic
Set-Service -Name SNMP -StartupType Automatic
Set-Service -Name SNMPTRAP -StartupType Automatic
Start-Service -Name SNMP
Start-Service -Name SNMPTRAP
# Seting SNMP Community (ex. public)
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities" -Name "public" -PropertyType DWord -Value 4 -Force
# Create Key PermittedManagers (Allow All)
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers" -Force
# Add Firewall Rule for SNMP UDP Port 161
if (-not (Get-NetFirewallRule -DisplayName "Allow SNMP UDP 161" -ErrorAction SilentlyContinue)) {
New-NetFirewallRule -DisplayName "Allow SNMP UDP 161" `
-Direction Inbound `
-Protocol UDP `
-LocalPort 161 `
-Action Allow `
-Profile Any `
-Enabled True
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment