Created
May 2, 2021 11:42
-
-
Save mmodrow/5598a74ec53d4da7f5ecee297bb6c2da to your computer and use it in GitHub Desktop.
Clean out print spooler from non-cancellable jobs by completely emptying the spooler.
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
$killPrintSpoolContent = { | |
Write-Host "Stopping print spooler." | |
Stop-Service -Name "Spooler" -Force -ErrorAction Continue | |
$queue = Get-ChildItem -Path "C:\WINDOWS\system32\spool\PRINTERS" -ErrorAction Continue | |
Write-Host "Deleting following print jobs from spooler:" | |
Write-Host $queue | |
$queue | Remove-Item -ErrorAction Continue | |
Start-Service -Name "Spooler" -ErrorAction Continue | |
Write-Host "Starting print spooler." | |
Read-Host “Press ENTER to continue...” | |
} | |
Write-Host "Escalating to admin privileges to manage services" | |
Start-Process -FilePath powershell.exe -ArgumentList $killPrintSpoolContent -verb RunAs -WorkingDirectory C: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment