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)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay