This commit is contained in:
Markus Fleschutz 2022-12-04 11:16:10 +01:00
commit aef9527491
2 changed files with 23 additions and 15 deletions

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Lists all jobs of all printers Lists all print jobs
.DESCRIPTION .DESCRIPTION
This PowerShell script lists all print jobs of all printer devices. This PowerShell script lists all print jobs of all printer devices.
.EXAMPLE .EXAMPLE
@ -14,18 +14,22 @@
#Requires -Version 4 #Requires -Version 4
try { try {
$printers = Get-Printer if ($IsLinux) {
if ($printers.Count -eq 0) { throw "No printer found" } # TODO
} else {
$printers = Get-Printer
if ($printers.Count -eq 0) { throw "No printer found" }
"" ""
"Printer Jobs" "Printer Jobs"
"------- ----" "------- ----"
foreach ($printer in $printers) { foreach ($printer in $printers) {
$printjobs = Get-PrintJob -PrinterObject $printer $printjobs = Get-PrintJob -PrinterObject $printer
if ($printjobs.Count -eq 0) { if ($printjobs.Count -eq 0) {
"$($printer.Name) none" "$($printer.Name) none"
} else { } else {
"$($printer.Name) $printjobs" "$($printer.Name) $printjobs"
}
} }
} }
exit 0 # success exit 0 # success

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Lists all printers known to the local computer Lists the printers
.DESCRIPTION .DESCRIPTION
This PowerShell script lists all printers known to the local computer. This PowerShell script lists all printers known to the local computer.
.EXAMPLE .EXAMPLE
@ -12,8 +12,12 @@
#> #>
try { try {
$ComputerName = $(hostname) if ($IsLinux) {
get-WMIObject -Class Win32_Printer -ComputerName $ComputerName | format-table # TODO
} else {
$ComputerName = $(hostname)
Get-WMIObject -Class Win32_Printer -ComputerName $ComputerName | Format-Table
}
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"