forked from iquzart/powershell-configure-SNMP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-SNMP.ps1
59 lines (39 loc) · 2.11 KB
/
configure-SNMP.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
######################################################################################################
# Description :- Powershell Script To Install/Configure SNMP Services (SNMP Service, SNMP WMI Provider)
# Author :- Muhammed Iqbal - Meraas IT
# Created :- 15-Aug-2019
# Updated :- 15-Aug-2019
# Version :- 0.1
# License :- MIT
# Notes :-
#####################################################################################################
#Requires -RunAsAdministrator
$MonitoringNode = "" # Your SNMP Monioring Node (IP or DNS name)
$CommunityString = "" # Your community string configured with Monitoring node.
# Configure SNMP service
function configure_SNMP {
Write-Host "Configuring SNMP-Services with your Community string and Monitoring Node"
Write-Host "------------------------------------------------------------------------"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v 1 /t REG_SZ /d localhost /f | Out-Null
Write-Host "1. Configuration of PermittedManger localhost: Done!"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v 2 /t REG_SZ /d $MonitoringNode /f | Out-Null
Write-Host "2. Configuration of PermittedManger $MonitoringNode : Done!"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities" /v $CommunityString /t REG_DWORD /d 4 /f | Out-Null
Write-Host "3. Configuration of Community String - $CommunityString : Done!"
}
Import-Module ServerManager
# Check if SNMP-Service Feature is enabled
$snmp_stat = Get-WindowsFeature -Name SNMP-Service
# Install/Enable SNMP-Service
If ($snmp_stat.Installed -ne "True") {
Write-Host "Enabling SNMP-Service Feature `n"
Get-WindowsFeature -name SNMP* | Add-WindowsFeature -IncludeManagementTools | Out-Null
configure_SNMP $MonitoringNode $CommunityString
}
ElseIf ($snmp_stat.Installed -eq "True") {
Write-Host "SNMP Services Already Installed `n"
configure_SNMP $MonitoringNode $CommunityString
}
Else {
Write-Host "SNMP Configuration Failed.!"
}