Created
April 12, 2019 14:17
-
-
Save Santaro255/d60e95c6867c9dcc97adfffa66cb5046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!(Get-InstalledModule -Name Proxx.SNMP)) { | |
try {Install-Module -Name Proxx.SNMP} | |
catch {Write-Host "`nYou need `"Proxx.SNMP`" module. Restart with administrator rights for installation or do it manually. (Install-Module -Name Proxx.SNMP)" -BackgroundColor DarkRed; break}} | |
$target=Read-Host -Prompt "Enter printer ip or hostname" | |
$connect=Test-Connection -ComputerName $target -Count 1 -ErrorAction SilentlyContinue | |
$ip=$connect.IPV4Address.IPAddressToString | |
$items=@{Model="1.3.6.1.2.1.25.3.2.1.3.1";#"1.3.6.1.2.1.43.5.1.1.16.1"; | |
SN="1.3.6.1.2.1.43.5.1.1.17.1" | |
Name="1.3.6.1.2.1.1.5.0"; | |
Uptime="1.3.6.1.2.1.1.3.0"; | |
Printed="1.3.6.1.2.1.43.10.2.1.5.1.1" | |
TotalPrinted="1.3.6.1.2.1.43.10.2.1.4.1.1" | |
TonerLeft="1.3.6.1.2.1.43.11.1.1.9.1.1" | |
TonerMax="1.3.6.1.2.1.43.11.1.1.8.1.1" | |
} | |
function gvalue($name) { | |
$value=Invoke-SnmpGet -IpAddress $ip -Oid $items.$name -ErrorAction SilentlyContinue | |
return $value.Value | |
} | |
if (!($connect)) {Write-Host "`nHost unreachable" -BackgroundColor DarkRed} | |
else { | |
Write-Host "`nName Value" | |
Write-Host "----- -----" | |
Write-Host "Model: "$(gvalue("Model")) | |
Write-Host "Serial Number: "$(gvalue("SN")) | |
Write-Host "Printer name: "$(gvalue("Name")) | |
Write-Host "Uptime: "$(gvalue("Uptime")) | |
Write-Host "Printed since last start: "$(gvalue("Printed")) | |
Write-Host "Total printed: "$(gvalue("TotalPrinted")) | |
Write-Host "Toner left: "$(gvalue("TonerLeft")) | |
Write-Host "Toner max: "$(gvalue("TonerMax")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment