Skip to content

Instantly share code, notes, and snippets.

@mmodrow
Created May 2, 2021 11:42
Show Gist options
  • Save mmodrow/5598a74ec53d4da7f5ecee297bb6c2da to your computer and use it in GitHub Desktop.
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.
$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