S
S
skoworodker2020-08-25 16:47:55
PowerShell
skoworodker, 2020-08-25 16:47:55

How to get mac address value from device via SNMP in powershell?

Can't get mac address value via snmp using powershell.

$SNMP = new-object -ComObject olePrn.OleSNMP
$SNMP.open($IP,"public",2,6000)
$mac = $SNMP.Get('.1.3.6.1.2.1.2.2.1.6.1')


$mac.lenght = 0
If you go through the tree (two network interfaces - two macs, one can be empty for loopback), then, according to the documentation, you should get a two-dimensional array of OID - value

$SNMP = new-object -ComObject olePrn.OleSNMP
$SNMP.open($IP,"public",2,6000)
$mac = [System.Text.Encoding]::Default.GetBytes($SNMP.GetTree('.1.3.6.1.2.1.2.2.1.6'))
[System.Text.Encoding]::Default.GetString($mac)


returns: interfaces.ifTable.ifEntry.ifPhysAddress.1 interfaces.ifTable.ifEntry.ifPhysAddress.2, only OIDs, no values.

Third-party software, such as snmpGet, or MIBBrowser mac in that OID sees the norms

OID=.1.3.6.1.2.1.2.2.1.6.1
Type=OctetString
Value= 00 C0 EE 3A 77 89

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2020-08-25
@skoworodker

It looks like a bug in the library
, I also have a poppy that starts with 00 does not show

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question