Skip to content

Instantly share code, notes, and snippets.

@jhoneill
Created April 8, 2026 13:17
Show Gist options
  • Select an option

  • Save jhoneill/033ebddd3f06b17779672abb575f0384 to your computer and use it in GitHub Desktop.

Select an option

Save jhoneill/033ebddd3f06b17779672abb575f0384 to your computer and use it in GitHub Desktop.
# Interesting printer infomation - accessible using the Simple Network management protocol (SNMP)
# Written for my Epson SC P700 but should work with other networked printers with SNMP support
param ($PrinterIP = "192.168.0.181")
enum SNMPPrinterStatus {
Other = 1
Unknown = 2
Idle = 3
Printing = 4
Warmup = 5
}
enum SNMPDoorStaus {
other = 1
DoorOpen = 3
DoorClosed = 4
InterlockOpen = 5
interlockClosed= 6
}
enum SNMPPrintUnits {
TenThousandthsOfInches = 3
Micrometers = 4
Characters = 5
Lines = 6
Impressions = 7
Sheets = 8
DotRow = 9
Hours = 11
Feet = 16
Meters = 17
}
#Using the COM object to avoid installing a PowerShell SNMP module :-)
$snmp = New-Object -ComObject olePrn.OleSNMP
$snmp.open($PrinterIP, 'public', 2, 1000)
$printerUptime = [timespan]::FromSeconds( $snmp.get(
".1.3.6.1.2.1.1.3.0") / 100)
$printerFirmware = $snmp.Get( ".1.3.6.1.2.1.2.2.1.2.1")
$printerModelName = $snmp.Get( ".1.3.6.1.2.1.25.3.2.1.3.1")
$printerStatus = $snmp.Get( ".1.3.6.1.2.1.43.5.1.1.3.1") -as [SNMPPrinterStatus]
$printerSerialNo = $snmp.Get( ".1.3.6.1.2.1.43.5.1.1.17.1")
$coverNames = $snmp.GetTree(".1.3.6.1.2.1.43.6.1.1.2.1")
$coverStatuses = $snmp.GetTree(".1.3.6.1.2.1.43.6.1.1.3.1")
$covers = for($i=0; $i -lt $coverNames.length/2; $i++){
[pscustomobject][ordered]@{Name = $coverNames[1,$i] ; Status = ($coverStatuses[1,$i] -as [SNMPDoorStaus])}
}
$printCountUnit = $snmp.Get( ".1.3.6.1.2.1.43.10.2.1.3.1.1") -as [SNMPPrintUnits]
$printCountTotal = $snmp.Get( ".1.3.6.1.2.1.43.10.2.1.4.1.1")
$consumableNames = $snmp.GetTree(".1.3.6.1.2.1.43.11.1.1.6.1")
$consumableLevels = $snmp.GetTree(".1.3.6.1.2.1.43.11.1.1.9.1")
$consumableMaximums = $snmp.GetTree(".1.3.6.1.2.1.43.11.1.1.8.1")
$snmp.Close()
# Consumables (i.e. Ink) are OUTPUT , Other bits are for humans to look at.
if ($covers.Status -like "*open*") {Write-host -ForegroundColor Yellow "Cover open"}
Write-host "$printerModelName, $printerFirmware, Serial no: $printerSerialNo. $printCountTotal $PrintCountUnit printed, Up-time: $printerUptime, Status: $printerStatus"
for ($i=0; $i -lt $consumableNames.length/2; $i++) {[pscustomobject][ordered]@{
Name = $consumableNames[1,$i];
Level = $consumableLevels[1,$i]
Max = $consumableMaximums[1,$i]
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment