Skip to content

Instantly share code, notes, and snippets.

@netaviator
Last active March 3, 2021 14:06
Show Gist options
  • Select an option

  • Save netaviator/8dfa6e847a1baa83fdd3ab9d64ce64d4 to your computer and use it in GitHub Desktop.

Select an option

Save netaviator/8dfa6e847a1baa83fdd3ab9d64ce64d4 to your computer and use it in GitHub Desktop.

Revisions

  1. MrXermon revised this gist Mar 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion powershell_w2k19_install_snmpd.ps1
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156
    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 "locahost"){
    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 {}
  2. MrXermon revised this gist Mar 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion powershell_w2k19_install_snmpd.ps1
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156
    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){
    if(Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1 -eq "locahost"){
    Remove-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1
    }
    }catch {}
  3. MrXermon revised this gist Mar 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion powershell_w2k19_install_snmpd.ps1
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156
    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 true){
    if(Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1){
    Remove-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1
    }
    }catch {}
  4. MrXermon revised this gist Feb 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion powershell_w2k19_install_snmpd.ps1
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #
    # Author: Jan Gilla
    # Company: level66.network UG (haftungsbeschränkt)
    # Description: BASH script to install snmpd daemon on Debian/Ubuntu based linx systems, generate the configuration and reload the service by using systemd.
    # Description: PowerShell script to install snmpd daemon on windows systems, generate the configuration and reload the service.
    #

    # Define variables here.
  5. MrXermon created this gist Feb 15, 2021.
    29 changes: 29 additions & 0 deletions powershell_w2k19_install_snmpd.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #
    # Author: Jan Gilla
    # Company: level66.network UG (haftungsbeschränkt)
    # Description: BASH script to install snmpd daemon on Debian/Ubuntu based linx systems, generate the configuration and reload the service by using systemd.
    #

    # 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 true){
    Remove-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers -Name 1
    }
    }catch {}

    Write-Host "Restart snmpd service via systemd ..."
    Restart-Service -Name SNMP