1

Closed

8 Bit Data

description

Hi
I try to get the MAC address from a switch .
When I use an standalone MIB-Browser I get the correct MAC "74:44:01:72:E2:37".
Now I do "$getmac=Invoke-SNMPget $line.IP $OID"
And then in the debugger:
[DBG]: PS C:\BackupNetworkDevices\test>> $getmac.Data
tDr?7


Now "tDr?7" translates to 74:44:01:72:3F:37
(same result when I convert $getmac.Data to a byte-array)

Can it be, that the dll has trouble with 8-Bit values (0xE2)? Or am I doing something wrong here?

Thanks for looking into this...
Regards
Thomas
Closed Oct 7, 2013 at 3:15 AM by lextm

comments

lextm wrote Oct 7, 2013 at 3:15 AM

You must dive deep enough to see what's the cause of this problem.

You should not call .Data if you want the bytes, as "74 44 01 72 E2 37" in this case is converted to tDr?7, where ? is used to represent a char that failed the conversion. Thus, when you again try to get the bytes from this string, you get the wrong bytes. The data loss occurs when ? char appears, not later in the process.

It is not an issue of #SNMP, but an issue of how you use the library. Please access the underlying bytes of OctetString via GetRaw method directly.

ThomasJF wrote Oct 14, 2013 at 8:14 AM

Of course you are right.
Thank you for putting my nose in the right direction.
Regards
Thomas