Querying Advanced Printer Info via SNMP

by Jan 23, 2023

Many network printer support SNMP to query information about the device, i.e. its serial number, the status and paper sizes of installed trays, or error information.

On Windows systems, the operating system already brings all components needed to do such SNMP queries via PowerShell. All you need to know is your printer’s IP address. Also, make sure it is turned on and supports SNMP.

Here is the script to try and test:

# define your printer network IP here:
$Printer_IP = '192.168.2.200'

# connect to printer:
$SNMP = New-Object -ComObject olePrn.OleSNMP
$SNMP.Open($Printer_IP,'public')

# get device description
$SNMP.Get(".1.3.6.1.2.1.25.3.2.1.3.1")
# get device serial number
$SNMP.Get(".1.3.6.1.2.1.43.5.1.1.17.1")
$SNMP.Close()

The code is rather short.

What’s more challenging is: what else could you find out besides device description and serial number? How do you know the ID numbers for the remaining pieces of information you can query. Here’s a list of the most commonly used IDs. Not all IDs are supported by all printers, though:

#region list of IDs that you can ask your printer:
# (not all IDs will work with all printers)
$OID_RAW_DATA = ".1.3.6.1.2.1.43.18.1.1"
$OID_CONSOLE_DATA = ".1.3.6.1.2.1.43.16"
$OID_CONTACT = ".1.3.6.1.2.1.1.4.0"
$OID_LOCATION = ".1.3.6.1.2.1.1.6.0"
$OID_SERIAL_NUMBER = ".1.3.6.1.2.1.43.5.1.1.17.1"
$OID_SYSTEM_DESCRIPTION = ".1.3.6.1.2.1.1.1.0"
$OID_DEVICE_DESCRIPTION = ".1.3.6.1.2.1.25.3.2.1.3.1"
$OID_DEVICE_STATE = ".1.3.6.1.2.1.25.3.2.1.5.1"
$OID_DEVICE_ERRORS = ".1.3.6.1.2.1.25.3.2.1.6.1"
$OID_UPTIME = ".1.3.6.1.2.1.1.3.0"
$OID_MEMORY_SIZE = ".1.3.6.1.2.1.25.2.2.0"
$OID_PAGE_COUNT = ".1.3.6.1.2.1.43.10.2.1.4.1.1"
$OID_HARDWARE_ADDRESS = ".1.3.6.1.2.1.2.2.1.6.1"
$OID_TRAY_1_NAME = ".1.3.6.1.2.1.43.8.2.1.13.1.1"
$OID_TRAY_1_CAPACITY = ".1.3.6.1.2.1.43.8.2.1.9.1.1"
$OID_TRAY_1_LEVEL = ".1.3.6.1.2.1.43.8.2.1.10.1.1"
$OID_TRAY_2_NAME = ".1.3.6.1.2.1.43.8.2.1.13.1.2"
$OID_TRAY_2_CAPACITY = ".1.3.6.1.2.1.43.8.2.1.9.1.2"
$OID_TRAY_2_LEVEL = ".1.3.6.1.2.1.43.8.2.1.10.1.2"
$OID_TRAY_3_NAME = ".1.3.6.1.2.1.43.8.2.1.13.1.3"
$OID_TRAY_3_CAPACITY = ".1.3.6.1.2.1.43.8.2.1.9.1.3"
$OID_TRAY_3_LEVEL = ".1.3.6.1.2.1.43.8.2.1.10.1.3"
$OID_TRAY_4_NAME = ".1.3.6.1.2.1.43.8.2.1.13.1.4"
$OID_TRAY_4_CAPACITY = ".1.3.6.1.2.1.43.8.2.1.9.1.4"
$OID_TRAY_4_LEVEL = ".1.3.6.1.2.1.43.8.2.1.10.1.4"
$OID_BLACK_TONER_CARTRIDGE_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.1"
$OID_BLACK_TONER_CARTRIDGE_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.1"
$OID_BLACK_TONER_CARTRIDGE_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.1"
$OID_CYAN_TONER_CARTRIDGE_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.2"
$OID_CYAN_TONER_CARTRIDGE_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.2"
$OID_CYAN_TONER_CARTRIDGE_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.2"
$OID_MAGENTA_TONER_CARTRIDGE_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.3"
$OID_MAGENTA_TONER_CARTRIDGE_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.3"
$OID_MAGENTA_TONER_CARTRIDGE_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.3"
$OID_YELLOW_TONER_CARTRIDGE_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.4"
$OID_YELLOW_TONER_CARTRIDGE_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.4"
$OID_YELLOW_TONER_CARTRIDGE_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.4"
$OID_WASTE_TONER_BOX_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.5"
$OID_WASTE_TONER_BOX_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.5"
$OID_WASTE_TONER_BOX_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.5"
$OID_BELT_UNIT_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.6"
$OID_BELT_UNIT_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.6"
$OID_BELT_UNIT_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.6"
$OID_BLACK_DRUM_UNIT_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.7"
$OID_BLACK_DRUM_UNIT_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.7"
$OID_BLACK_DRUM_UNIT_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.7"
$OID_CYAN_DRUM_UNIT_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.8"
$OID_CYAN_DRUM_UNIT_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.8"
$OID_CYAN_DRUM_UNIT_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.8"
$OID_MAGENTA_DRUM_UNIT_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.9"
$OID_MAGENTA_DRUM_UNIT_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.9"
$OID_MAGENTA_DRUM_UNIT_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.9"
$OID_YELLOW_DRUM_UNIT_NAME = ".1.3.6.1.2.1.43.11.1.1.6.1.10"
$OID_YELLOW_DRUM_UNIT_CAPACITY = ".1.3.6.1.2.1.43.11.1.1.8.1.10"
$OID_YELLOW_DRUM_UNIT_LEVEL = ".1.3.6.1.2.1.43.11.1.1.9.1.10"
#endregion

Tweet this Tip! Tweet this Tip!