FunctionNew-XeroxMeterReading{<#.SYNOPSIS Queries a Xerox printer for Black and Color Meter readings..DESCRIPTION This script successfully reads the meter of Versalink C405, C400, B400, AltaLink C8035, C8055 devices. Use on other Xerox models has not been tested, however, may work.PARAMETER InputPrinterFile The path to a CSV containing printer information such as IP, hostname, etc.PARAMETER OutputFile The destination file for collection results (If wanted.) Email will always be sent..PARAMETER BlackOID The OID string of the Black toner meter.PARAMETER ColorOID The OID string of the Color toner meter #>Param([cmdletBinding()][parameter(Mandatory,Position=0)][string]$InputPrinterFile,[parameter(Mandatory=$false,Position=1)][string]$OutputFile,[Parameter(Mandatory,Position=2)][string]$BlackOID,[Parameter(Mandatory,Position=3)][string]$ColorOID)If(!(Test-PathC:\usr\bin\snmpget.exe)){Write-Error-Message"Required Library Net-SNMP not found! Install: https://goo.gl/LoLJGU"Break}$Printers=Import-Csv$InputPrinterFileForeach($Pin$Printers){If(!(Test-Connection$P.'IP Address'-Quiet-Count1)){Out-Null}Else{$black=C:\usr\bin\snmpget.exe-v2c-cTusc-Print-Ov$P.'IP Address'$BlackOID$color=C:\usr\bin\snmpget.exe-v2c-cTusc-Print-Ov$P.'IP Address'$ColorOID$P.'Black Meter'=[int]$blackMeter=$black.Split(':')[1].Trim()If($color-eq"No Such Instance currently exists at this OID"){$P.'Color Meter'=[int]$colorMeter=0}Else{$P.'Color Meter'=[int]$colorMeter=$color.Split(':')[1].Trim()}$P.Total=[int]$totalMeter=$blackMeter+$colorMeter}#else}#foreach#populate lines 78-80 as needed$params=@{'SmtpServer'='''To'='''From'='''Subject'="Monthly Meter Reading For $((Get-Date).Month)/$((Get-Date).Year)"'Body'=$Printers|ConvertTo-Html-Fragment|Out-String}Send-MailMessage@params-BodyAsHtmlIf($OutputFile){$Printers|Export-CSV-Path$OutputFile-Append-NoTypeInformation}}#function
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.