NetCmdlets: How to Specify an IP Address Using Set-SNMP

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.")

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.