Add remove-print-jobs.ps1

This commit is contained in:
Markus Fleschutz
2021-08-30 10:17:34 +02:00
parent 231ca5b746
commit 946a037624
3 changed files with 30 additions and 0 deletions

28
Scripts/remove-print-jobs.ps1 Executable file
View File

@ -0,0 +1,28 @@
#requires -version 4
<#
.SYNOPSIS
remove-print-jobs.ps1
.DESCRIPTION
removes all jobs from all printers
.EXAMPLE
PS> .\remove-print-jobs.ps1
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
https://github.com/fleschutz/PowerShell
#>
try {
$printers = Get-Printer
foreach ($printer in $printers) {
$printjobs = Get-PrintJob -PrinterObject $printer
foreach ($printjob in $printjobs) {
Remove-PrintJob -InputObject $printjob
}
"✔️ removed all jobs from all printers"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}