uspeoples

PrintTonerReport.ps1

Dec 23rd, 2014
2,621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $printerlist = import-csv .\printerlist.txt -header Value,Name,Description
  2. $outfile = ".\PrinterReport.html"
  3. $SNMP = new-object -ComObject olePrn.OleSNMP
  4. $ErrorActionPreference = "Continue"
  5. $total = ($printerlist.value|? {$_ -notlike "-*"}).length
  6.  
  7. Write "`
  8. <html>`
  9. <head>`
  10. <title>Printer Report</title>`
  11. <style>* {font-family:'Trebuchet MS';}</style>`
  12. </head>`
  13. <body>"|out-file $outfile
  14.  
  15. write "Reporting on $total printers"
  16. $x = 0
  17.  
  18. foreach ($p in $printerlist){
  19.  
  20. if ($p.value -like "-*"){write "<h3>",$p.value.replace('-',''),"</h3>"|add-content $outfile}
  21.  
  22. if ($p.value -notlike "-*"){
  23.  
  24. $x = $x + 1
  25. $printertype = $nul
  26. $status = $nul
  27. $percentremaining = $nul
  28. $blackpercentremaining = $nul
  29. $cyanpercentremaining = $nul
  30. $magentapercentremaining = $nul
  31. $yellowpercentremaining = $nul
  32. $wastepercentremaining = $nul
  33.  
  34. if (!(test-connection $p.Value -Quiet -count 1)){write ($p.value + " is offline<br>")|add-content $outfile}
  35. if (test-connection $p.value -quiet -count 1){
  36. $snmp.open($p.value,"public",2,3000)
  37. $printertype = $snmp.Get(".1.3.6.1.2.1.25.3.2.1.3.1")
  38. write ([string]$x + ": " + [string]$p.Value + " " + $printertype)
  39. }
  40.  
  41. if ($printertype -like "*WorkCentre 5655*"){
  42.  
  43. $tonervolume = $snmp.get("43.11.1.1.8.1.1")
  44. $currentvolume = $snmp.get("43.11.1.1.9.1.1")
  45. [int]$percentremaining = 100 - (($currentvolume / $tonervolume) * 100)
  46.  
  47. $statustree = $snmp.gettree("43.18.1.1.8")
  48. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  49. $status = $status|? {$_ -notlike "*bypass*"}
  50. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  51. if ($name -notlike "PX*"){$name = $p.name}
  52.  
  53. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  54. if ($percentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  55. if (($percentremaining -gt 24) -and ($percentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  56. if (($percentremaining -gt 10) -and ($percentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  57. if (($percentremaining -ge 0) -and ($percentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  58. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  59. }
  60.  
  61.  
  62. if ($printertype -like "*WorkCentre 5675*"){
  63.  
  64. $tonervolume = $snmp.get("43.11.1.1.8.1.1")
  65. $currentvolume = $snmp.get("43.11.1.1.9.1.1")
  66. [int]$percentremaining = ($currentvolume / $tonervolume) * 100
  67. $statustree = $snmp.gettree("43.18.1.1.8")
  68. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  69. $status = $status|? {$_ -notlike "*bypass*"}
  70. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  71. if ($name -notlike "PX*"){$name = $p.name}
  72.  
  73. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  74. if ($percentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  75. if (($percentremaining -gt 24) -and ($percentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  76. if (($percentremaining -gt 10) -and ($percentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  77. if (($percentremaining -ge 0) -and ($percentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  78. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  79. }
  80.  
  81. if ($printertype -like "*WorkCentre 3325*"){
  82.  
  83. $tonervolume = $snmp.get("43.11.1.1.8.1.1")
  84. $currentvolume = $snmp.get("43.11.1.1.9.1.1")
  85. [int]$percentremaining = ($currentvolume / $tonervolume) * 100
  86. $statustree = $snmp.gettree("43.18.1.1.8")
  87. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  88. $status = $status|? {$_ -notlike "*bypass*"}
  89. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  90. if ($name -notlike "PX*"){$name = $p.name}
  91.  
  92. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  93. if ($percentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  94. if (($percentremaining -gt 24) -and ($percentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  95. if (($percentremaining -gt 10) -and ($percentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  96. if (($percentremaining -ge 0) -and ($percentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  97. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  98. }
  99.  
  100. if ($printertype -like "*Phaser 3635*"){
  101.  
  102. $tonervolume = $snmp.get("43.11.1.1.8.1.1")
  103. $currentvolume = $snmp.get("43.11.1.1.9.1.1")
  104. [int]$percentremaining = ($currentvolume / $tonervolume) * 100
  105. $statustree = $snmp.gettree("43.18.1.1.8")
  106. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  107. $status = $status|? {$_ -notlike "*bypass*"}
  108. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  109. if ($name -notlike "PX*"){$name = $p.name}
  110.  
  111. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  112. if ($percentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  113. if (($percentremaining -gt 24) -and ($percentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  114. if (($percentremaining -gt 10) -and ($percentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  115. if (($percentremaining -ge 0) -and ($percentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  116. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  117. }
  118.  
  119. if ($printertype -like "*Phaser 3610*"){
  120.  
  121. $tonervolume = $snmp.get("43.11.1.1.8.1.1")
  122. $currentvolume = $snmp.get("43.11.1.1.9.1.1")
  123. [int]$percentremaining = ($currentvolume / $tonervolume) * 100
  124. $statustree = $snmp.gettree("43.18.1.1.8")
  125. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  126. $status = $status|? {$_ -notlike "*bypass*"}
  127. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  128. if ($name -notlike "PX*"){$name = $p.name}
  129.  
  130. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  131. if ($percentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  132. if (($percentremaining -gt 24) -and ($percentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  133. if (($percentremaining -gt 10) -and ($percentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  134. if (($percentremaining -ge 0) -and ($percentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$percentremaining,"</b>% black toner<br>"|add-content $outfile}
  135. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  136. }
  137.  
  138. if ($printertype -like "*Ricoh Aficio*"){
  139.  
  140. $statustree = $snmp.gettree("43.18.1.1.8")
  141. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  142. $status = $status|? {$_ -notlike "*bypass*"}
  143. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  144.  
  145. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  146. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  147. }
  148.  
  149.  
  150. if ($printertype -like "*WorkCentre 7835*"){
  151.  
  152. $blacktonervolume = $snmp.get("43.11.1.1.8.1.1")
  153. $blackcurrentvolume = $snmp.get("43.11.1.1.9.1.1")
  154. [int]$blackpercentremaining = ($blackcurrentvolume / $blacktonervolume) * 100
  155. $cyantonervolume = $snmp.get("43.11.1.1.8.1.2")
  156. $cyancurrentvolume = $snmp.get("43.11.1.1.9.1.2")
  157. [int]$cyanpercentremaining = ($cyancurrentvolume / $cyantonervolume) * 100
  158. $magentatonervolume = $snmp.get("43.11.1.1.8.1.3")
  159. $magentacurrentvolume = $snmp.get("43.11.1.1.9.1.3")
  160. [int]$magentapercentremaining = ($magentacurrentvolume / $magentatonervolume) * 100
  161. $yellowtonervolume = $snmp.get("43.11.1.1.8.1.4")
  162. $yellowcurrentvolume = $snmp.get("43.11.1.1.9.1.4")
  163. [int]$yellowpercentremaining = ($yellowcurrentvolume / $yellowtonervolume) * 100
  164. $wastetonervolume = $snmp.get("43.11.1.1.8.1.10")
  165. $wastecurrentvolume = [math]::round([math]::abs($snmp.get("43.11.1.1.9.1.10")))
  166. [int]$wastepercentremaining = (($wastecurrentvolume / $wastetonervolume) * 100)
  167.  
  168. $statustree = $snmp.gettree("43.18.1.1.8")
  169. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  170. $status = $status|? {$_ -notlike "*bypass*"}
  171. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  172. if ($name -notlike "PX*"){$name = $p.name}
  173.  
  174. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  175. if ($blackpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  176. if (($blackpercentremaining -gt 24) -and ($blackpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  177. if (($blackpercentremaining -gt 10) -and ($blackpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  178. if (($blackpercentremaining -ge 0) -and ($blackpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  179. if ($cyanpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  180. if (($cyanpercentremaining -gt 24) -and ($cyanpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  181. if (($cyanpercentremaining -gt 10) -and ($cyanpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  182. if (($cyanpercentremaining -ge 0) -and ($cyanpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  183. if ($magentapercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  184. if (($magentapercentremaining -gt 24) -and ($magentapercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  185. if (($magentapercentremaining -gt 10) -and ($magentapercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  186. if (($magentapercentremaining -ge 0) -and ($magentapercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  187. if ($yellowpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  188. if (($yellowpercentremaining -gt 24) -and ($yellowpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  189. if (($yellowpercentremaining -gt 10) -and ($yellowpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  190. if (($yellowpercentremaining -ge 0) -and ($yellowpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  191. if ($wastepercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  192. if (($wastepercentremaining -gt 24) -and ($wastepercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  193. if (($wastepercentremaining -gt 10) -and ($wastepercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  194. if (($wastepercentremaining -ge 0) -and ($wastepercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  195. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  196. }
  197.  
  198. if ($printertype -like "*Phaser 7100*"){
  199.  
  200. $blacktonervolume = $snmp.get("43.11.1.1.8.1.1")
  201. $blackcurrentvolume = $snmp.get("43.11.1.1.9.1.1")
  202. [int]$blackpercentremaining = ($blackcurrentvolume / $blacktonervolume) * 100
  203. $cyantonervolume = $snmp.get("43.11.1.1.8.1.4")
  204. $cyancurrentvolume = $snmp.get("43.11.1.1.9.1.4")
  205. [int]$cyanpercentremaining = ($cyancurrentvolume / $cyantonervolume) * 100
  206. $magentatonervolume = $snmp.get("43.11.1.1.8.1.3")
  207. $magentacurrentvolume = $snmp.get("43.11.1.1.9.1.3")
  208. [int]$magentapercentremaining = ($magentacurrentvolume / $magentatonervolume) * 100
  209. $yellowtonervolume = $snmp.get("43.11.1.1.8.1.2")
  210. $yellowcurrentvolume = $snmp.get("43.11.1.1.9.1.2")
  211. [int]$yellowpercentremaining = ($yellowcurrentvolume / $yellowtonervolume) * 100
  212. $wastetonervolume = $snmp.get("43.11.1.1.8.1.5")
  213. $wastecurrentvolume = [math]::round([math]::abs($snmp.get("43.11.1.1.9.1.5")))
  214. [int]$wastepercentremaining = 100 - (($wastecurrentvolume / $wastetonervolume) * 100)
  215.  
  216. $statustree = $snmp.gettree("43.18.1.1.8")
  217. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  218. $status = $status|? {$_ -notlike "*bypass*"}
  219. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  220. if ($name -notlike "PX*"){$name = $p.name}
  221.  
  222. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  223. if ($blackpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  224. if (($blackpercentremaining -gt 24) -and ($blackpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  225. if (($blackpercentremaining -gt 10) -and ($blackpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  226. if (($blackpercentremaining -ge 0) -and ($blackpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  227. if ($cyanpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  228. if (($cyanpercentremaining -gt 24) -and ($cyanpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  229. if (($cyanpercentremaining -gt 10) -and ($cyanpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  230. if (($cyanpercentremaining -ge 0) -and ($cyanpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  231. if ($magentapercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  232. if (($magentapercentremaining -gt 24) -and ($magentapercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  233. if (($magentapercentremaining -gt 10) -and ($magentapercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  234. if (($magentapercentremaining -ge 0) -and ($magentapercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  235. if ($yellowpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  236. if (($yellowpercentremaining -gt 24) -and ($yellowpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  237. if (($yellowpercentremaining -gt 10) -and ($yellowpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  238. if (($yellowpercentremaining -ge 0) -and ($yellowpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  239. if ($wastepercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  240. if (($wastepercentremaining -gt 24) -and ($wastepercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  241. if (($wastepercentremaining -gt 10) -and ($wastepercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  242. if (($wastepercentremaining -ge 0) -and ($wastepercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  243. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  244. }
  245.  
  246. if (($printertype -like "*660*") -and ($printertype -like "*Xerox*") -and ($printertype -like "*DN*")){
  247.  
  248. $blacktonervolume = $snmp.get("43.11.1.1.8.1.4")
  249. $blackcurrentvolume = $snmp.get("43.11.1.1.9.1.4")
  250. [int]$blackpercentremaining = ($blackcurrentvolume / $blacktonervolume) * 100
  251. $cyantonervolume = $snmp.get("43.11.1.1.8.1.1")
  252. $cyancurrentvolume = $snmp.get("43.11.1.1.9.1.1")
  253. [int]$cyanpercentremaining = ($cyancurrentvolume / $cyantonervolume) * 100
  254. $magentatonervolume = $snmp.get("43.11.1.1.8.1.2")
  255. $magentacurrentvolume = $snmp.get("43.11.1.1.9.1.2")
  256. [int]$magentapercentremaining = ($magentacurrentvolume / $magentatonervolume) * 100
  257. $yellowtonervolume = $snmp.get("43.11.1.1.8.1.3")
  258. $yellowcurrentvolume = $snmp.get("43.11.1.1.9.1.3")
  259. [int]$yellowpercentremaining = ($yellowcurrentvolume / $yellowtonervolume) * 100
  260. $wastetonervolume = $snmp.get("43.11.1.1.8.1.6")
  261. $wastecurrentvolume = [math]::round([math]::abs($snmp.get("43.11.1.1.9.1.6")))
  262. [int]$wastepercentremaining = (($wastecurrentvolume / $wastetonervolume) * 100)
  263.  
  264. $statustree = $snmp.gettree("43.18.1.1.8")
  265. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  266. $status = $status|? {$_ -notlike "*bypass*"}
  267. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  268. if ($name -notlike "PX*"){$name = $p.name}
  269.  
  270. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  271. if ($blackpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  272. if (($blackpercentremaining -gt 24) -and ($blackpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  273. if (($blackpercentremaining -gt 10) -and ($blackpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  274. if (($blackpercentremaining -ge 0) -and ($blackpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$blackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  275. if ($cyanpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  276. if (($cyanpercentremaining -gt 24) -and ($cyanpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  277. if (($cyanpercentremaining -gt 10) -and ($cyanpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  278. if (($cyanpercentremaining -ge 0) -and ($cyanpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  279. if ($magentapercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  280. if (($magentapercentremaining -gt 24) -and ($magentapercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  281. if (($magentapercentremaining -gt 10) -and ($magentapercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  282. if (($magentapercentremaining -ge 0) -and ($magentapercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  283. if ($yellowpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  284. if (($yellowpercentremaining -gt 24) -and ($yellowpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  285. if (($yellowpercentremaining -gt 10) -and ($yellowpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  286. if (($yellowpercentremaining -ge 0) -and ($yellowpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  287. if ($wastepercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  288. if (($wastepercentremaining -gt 24) -and ($wastepercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  289. if (($wastepercentremaining -gt 10) -and ($wastepercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  290. if (($wastepercentremaining -ge 0) -and ($wastepercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$wastepercentremaining,"</b>% waste toner<br>"|add-content $outfile}
  291. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  292. }
  293.  
  294.  
  295. if ($printertype -like "*HP Designjet T1500*"){
  296.  
  297. $pblacktonervolume = $snmp.get("43.11.1.1.8.1.1")
  298. $pblackcurrentvolume = $snmp.get("43.11.1.1.9.1.1")
  299. [int]$pblackpercentremaining = ($pblackcurrentvolume / $pblacktonervolume) * 100
  300. $graytonervolume = $snmp.get("43.11.1.1.8.1.2")
  301. $graycurrentvolume = $snmp.get("43.11.1.1.9.1.2")
  302. [int]$graypercentremaining = ($graycurrentvolume / $graytonervolume) * 100
  303. $mblacktonervolume = $snmp.get("43.11.1.1.8.1.3")
  304. $mblackcurrentvolume = $snmp.get("43.11.1.1.9.1.3")
  305. [int]$mblackpercentremaining = ($mblackcurrentvolume / $mblacktonervolume) * 100
  306. $cyantonervolume = $snmp.get("43.11.1.1.8.1.4")
  307. $cyancurrentvolume = $snmp.get("43.11.1.1.9.1.4")
  308. [int]$cyanpercentremaining = ($cyancurrentvolume / $cyantonervolume) * 100
  309. $magentatonervolume = $snmp.get("43.11.1.1.8.1.5")
  310. $magentacurrentvolume = $snmp.get("43.11.1.1.9.1.5")
  311. [int]$magentapercentremaining = ($magentacurrentvolume / $magentatonervolume) * 100
  312. $yellowtonervolume = $snmp.get("43.11.1.1.8.1.6")
  313. $yellowcurrentvolume = $snmp.get("43.11.1.1.9.1.6")
  314. [int]$yellowpercentremaining = ($yellowcurrentvolume / $yellowtonervolume) * 100
  315.  
  316. $statustree = $snmp.gettree("43.18.1.1.8")
  317. $status = $statustree|? {$_ -notlike "print*"} #status, including low ink warnings
  318. $status = $status|? {$_ -notlike "*bypass*"}
  319. $name = $snmp.get(".1.3.6.1.2.1.1.5.0")
  320. if ($name -notlike "PH*"){$name = $p.name}
  321.  
  322. write ("<b>" + $p.description + "</b><a style='text-decoration:none;font-weight:bold;' href=http://" + $p.value + " target='_new'> " + $name + "</a> <br>" + $printertype + "<br>")|add-content $outfile
  323. if ($pblackpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$pblackpercentremaining,"</b>% black toner<br>"|add-content $outfile}
  324. if (($pblackpercentremaining -gt 24) -and ($pblackpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$pblackpercentremaining,"</b>% photo black toner<br>"|add-content $outfile}
  325. if (($pblackpercentremaining -gt 10) -and ($pblackpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$pblackpercentremaining,"</b>% photo black toner<br>"|add-content $outfile}
  326. if (($pblackpercentremaining -ge 0) -and ($pblackpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$pblackpercentremaining,"</b>% photo black toner<br>"|add-content $outfile}
  327. if ($graypercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$graypercentremaining,"</b>% gray toner<br>"|add-content $outfile}
  328. if (($graypercentremaining -gt 24) -and ($graypercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$graypercentremaining,"</b>% gray toner<br>"|add-content $outfile}
  329. if (($graypercentremaining -gt 10) -and ($graypercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$graypercentremaining,"</b>% gray toner<br>"|add-content $outfile}
  330. if (($graypercentremaining -ge 0) -and ($graypercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$graypercentremaining,"</b>% gray toner<br>"|add-content $outfile}
  331. if ($mblackpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$mblackpercentremaining,"</b>% matte black toner<br>"|add-content $outfile}
  332. if (($mblackpercentremaining -gt 24) -and ($mblackpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$mblackpercentremaining,"</b>% matte black toner<br>"|add-content $outfile}
  333. if (($mblackpercentremaining -gt 10) -and ($mblackpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$mblackpercentremaining,"</b>% matte black toner<br>"|add-content $outfile}
  334. if (($mblackpercentremaining -ge 0) -and ($mblackpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$mblackpercentremaining,"</b>% matte black toner<br>"|add-content $outfile}
  335. if ($cyanpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  336. if (($cyanpercentremaining -gt 24) -and ($cyanpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  337. if (($cyanpercentremaining -gt 10) -and ($cyanpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  338. if (($cyanpercentremaining -ge 0) -and ($cyanpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$cyanpercentremaining,"</b>% cyan toner<br>"|add-content $outfile}
  339. if ($magentapercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  340. if (($magentapercentremaining -gt 24) -and ($magentapercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  341. if (($magentapercentremaining -gt 10) -and ($magentapercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  342. if (($magentapercentremaining -ge 0) -and ($magentapercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$magentapercentremaining,"</b>% magenta toner<br>"|add-content $outfile}
  343. if ($yellowpercentremaining -gt 49){write "<b style='font-size:110%;color:green;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  344. if (($yellowpercentremaining -gt 24) -and ($yellowpercentremaining -le 49)){write "<b style='font-size:110%;color:#40BB30;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  345. if (($yellowpercentremaining -gt 10) -and ($yellowpercentremaining -le 24)){write "<b style='font-size:110%;color:orange;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  346. if (($yellowpercentremaining -ge 0) -and ($yellowpercentremaining -le 10)){write "<b style='font-size:110%;color:red;'>",$yellowpercentremaining,"</b>% yellow toner<br>"|add-content $outfile}
  347.  
  348. if ($status.length -gt 0){write ($status + "<br><br>")|add-content $outfile}else{write "Operational<br><br>"|add-content $outfile}
  349. }
  350.  
  351.  
  352.  
  353. }
  354. }
  355. &$outfile
Advertisement
Add Comment
Please, Sign In to add comment