Last active
March 3, 2021 14:06
-
-
Save netaviator/8dfa6e847a1baa83fdd3ab9d64ce64d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Author: Jan Gilla | |
# Company: level66.network UG (haftungsbeschränkt) | |
# Description: PowerShell script to install snmpd daemon on windows systems, generate the configuration and reload the service. | |
# | |
# Define variables here. | |
$SNMPD_COMMUNITY = "public" | |
$SNMPD_LOCATION = "Milki Way" | |
$SNMPD_CONTACT = "[email protected]" | |
# Do not change anything below here! | |
Write-Host "Installing snmpd service via Windows Features ..." | |
Import-Module ServerManager | |
Install-WindowsFeature SNMP-Service | Out-Null | |
Install-WindowsFeature SNMP-WMI-Provider | Out-Null | |
Write-Host "Deploy configuration to service ..." | |
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent -Name sysLocation -Type String -Value $SNMPD_LOCATION | |
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent -Name sysContact -Type String -Value $SNMPD_CONTACT | |
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities -Name $SNMPD_COMMUNITY -Type DWord -Value 0x4 | |
try { | |
if(Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1 -eq "localhost"){ | |
Remove-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1 | |
} | |
}catch {} | |
Write-Host "Restart snmpd service via systemd ..." | |
Restart-Service -Name SNMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment