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

View File

@ -179,6 +179,7 @@ new-email.ps1, starts the default email client to write a new email
reboot.ps1, reboots the local computer (needs admin rights) reboot.ps1, reboots the local computer (needs admin rights)
reboot-fritzbox.ps1, reboots the FRITZ!box device reboot-fritzbox.ps1, reboots the FRITZ!box device
remove-empty-dirs.ps1, removes empty subfolders within the given directory tree remove-empty-dirs.ps1, removes empty subfolders within the given directory tree
remove-print-jobs.ps1, removes all jobs from all printers
restart-network-adapters.ps1, restarts all local network adapters restart-network-adapters.ps1, restarts all local network adapters
search-filename.ps1, searches the directory tree for filenames by given pattern search-filename.ps1, searches the directory tree for filenames by given pattern
search-files.ps1, searches the given pattern in the given files search-files.ps1, searches the given pattern in the given files

Can't render this file because it has a wrong number of fields in line 86.

View File

@ -81,6 +81,7 @@ Mega Collection of PowerShell Scripts
| [poweroff.ps1](Scripts/poweroff.ps1) | halts the local computer (needs admin rights) | [poweroff.ps1](Scripts/poweroff.ps1) | halts the local computer (needs admin rights)
| [query-smart-data.ps1](Scripts/query-smart-data.ps1) | queries the S.M.A.R.T. data of your HDD/SSD's | [query-smart-data.ps1](Scripts/query-smart-data.ps1) | queries the S.M.A.R.T. data of your HDD/SSD's
| [reboot.ps1](Scripts/reboot.ps1) | reboots the local computer (needs admin rights) | [reboot.ps1](Scripts/reboot.ps1) | reboots the local computer (needs admin rights)
| [remove-print-jobs.ps1](Scripts/remove-print-jobs.ps1) | removes all jobs from all printers
| [restart-network-adapters.ps1](Scripts/restart-network-adapters.ps1) | restarts all local network adapters | [restart-network-adapters.ps1](Scripts/restart-network-adapters.ps1) | restarts all local network adapters
| [upgrade-ubuntu.ps1](Scripts/upgrade-ubuntu.ps1) | upgrades Ubuntu Linux to the latest (LTS) release | [upgrade-ubuntu.ps1](Scripts/upgrade-ubuntu.ps1) | upgrades Ubuntu Linux to the latest (LTS) release
| [wakeup.ps1](Scripts/wakeup.ps1) | sends a magic packet a computer to wake him up | [wakeup.ps1](Scripts/wakeup.ps1) | sends a magic packet a computer to wake him up

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
}