Update list-print-jobs.ps1

This commit is contained in:
Markus Fleschutz 2022-12-04 12:02:06 +01:00
parent 91ba386b39
commit 6b5a40a7b1

View File

@ -13,24 +13,27 @@
#Requires -Version 4
function ListPrintJobs {
$printers = Get-Printer
if ($printers.Count -eq 0) { throw "No printer found" }
foreach ($printer in $printers) {
$PrinterName = $printer.Name
$printjobs = Get-PrintJob -PrinterObject $printer
if ($printjobs.Count -eq 0) {
$PrintJobs = "none"
} else {
$PrintJobs = "$printjobs"
}
New-Object PSObject -Property @{ Printer=$PrinterName; Jobs=$PrintJobs }
}
}
try {
if ($IsLinux) {
# TODO
} else {
$printers = Get-Printer
if ($printers.Count -eq 0) { throw "No printer found" }
""
"Printer Jobs"
"------- ----"
foreach ($printer in $printers) {
$printjobs = Get-PrintJob -PrinterObject $printer
if ($printjobs.Count -eq 0) {
"$($printer.Name) none"
} else {
"$($printer.Name) $printjobs"
}
}
ListPrintJobs | Format-Table -property Printer,Jobs
}
exit 0 # success
} catch {