This commit is contained in:
2020-08-18 16:20:20 -04:00
parent 98fb3928c5
commit cb110b354d
26 changed files with 225 additions and 201 deletions
+22
View File
@@ -0,0 +1,22 @@
## Make sure the spooler service isn't already stopped
If ( (Get-Service -Name spooler).Status -ne "Stopped" )
{
## Forcefully stop the spooler service
Stop-Service -Name spooler -Force
## Wait a few seconds to make sure it's stopped
Start-Sleep -Seconds 5
}
## Check to make sure the spooler service has stopped
If ((Get-Service -Name spooler).Status -eq "Stopped")
{
## Delete all print jobs, including secure prints
Remove-Item "${Env:WINDIR}\System32\spool\PRINTERS\*" -Recurse
## Start the spooler service again
Start-Service -Name spooler
}
## If the spooler service didn't stop on time, just return an error
Else { Write-Output "Could not clean ${Env:WINDIR}\System32\spool\PRINTERS\* because spooler service is running." }