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



In order to set an IP Address value using Set-SNMP, "IPAddress" should be passed to the Type parameter. From there, the cmdlet 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 Type is not specified, then the cmdlet will use "OctetString" by default, resulting in a loss of information, 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 designated)
Set-SNMP $someAddr -oid $someOID -value "172.18.1.30"

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