A hidden gem – SNMP

SNMP tools hidden in printers! using olePrn.OleSNMP to confirm provided SNMP information is correct

Something I had found odd for sometime was a lack of SNMP polling within PowerShell. The tool is so powerful so why can’t we query pesky switches, printer and other IT equipment for small, fast and useful data. Sure we could use one of many available CLI or GUI tools, but plain text/string manipulation is a pain! Well it turns out its hidden in an obscure place, within olePrn.OleSNMP ComObject. I don’t recall where I came across this information originally, but thank you GoogleFu for finding it.

The only information we need to use to make this work: A hostname or IP, read community string and an OID we wish to query.

$SNMP = New-Object -ComObject olePrn.OleSNMP
$snmp.open(‘host’,’community string’,attempts#,timeout(ms))
$snmp.get(‘an oid’)

$SNMP = New-Object -ComObject olePrn.OleSNMP
$snmp.open('192.168.23.201','PowerShellIsCool',2,1000)
$snmp.get('.1.3.6.1.2.1.1.1.0')

Continue reading “A hidden gem – SNMP”