How Set-SNMP processes values passed as type “IPAddress”



When a user wants to set an IP Address value using Set-SNMP, he should pass “IPAddress” to the “-type” parameter. From there, our software will convert each quadrant of the value to a byte, resulting in four bytes being sent to the server.

#Passing a value of "172.18.1.30" as an "IPAddress"
Set-SNMP $someAddr -oid $someOID -value "172.18.1.30" -type "IPAddress"

#What gets sent the the server: 0xAC 0x12 0x01 0x1E

If a user does not specify a “-type” then our Cmdlet will use “OctetString” by default, resulting in a loss of information to the server as only the first four bytes of the ASCII string will be sent.

#Passing a value of "172.18.1.30" as an "OctetString" (no -type is deisgnated)
Set-SNMP $someAddr -oid $someOID -value "172.18.1.30"

#What gets sent the the server: 0x31 0x37 0x32 0x2E ("172.")