23 lines
800 B
PowerShell
23 lines
800 B
PowerShell
## 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 to the Ninja Activity Stream
|
|
Else { Write-Output "Could not clean ${Env:WINDIR}\System32\spool\PRINTERS\* because spooler service is running." }
|