DEV Community

terminalpuncher.com
terminalpuncher.com

Posted on

Querying SNMP in PowerShell

Within Windows use the following one liner to gather The "ValidCommunities" key which holds the community strings configured.

Get-ChildItem -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters' -Recurse
Enter fullscreen mode Exit fullscreen mode

The PermittedManagers key holds the SNMP server info and the item property name is incrementing numbers starting at 0 and the item property value is the name or IP address of the SNMP server.

Once you have those details add to the below code.

$SNMP = New-Object -ComObject olePrn.OleSNMP
$snmp.open('localhost','public',2,1000)
$snmp.get('.1.3.6.1.2.1.1.1.0')
Enter fullscreen mode Exit fullscreen mode

Top comments (0)