2021-06-02 16:16:24 -04:00
|
|
|
$SERVICE = 'spooler'
|
2020-08-18 16:20:20 -04:00
|
|
|
|
2021-06-02 16:16:24 -04:00
|
|
|
## Make sure the service isn't disabled
|
|
|
|
|
If (! ($(Get-Service -Name 'spooler').StartType -eq "Disabled") ) {
|
2020-08-18 16:20:20 -04:00
|
|
|
|
2021-06-02 16:16:24 -04:00
|
|
|
## Stop the spooler service
|
|
|
|
|
Control-Service -Stop -Name $SERVICE
|
|
|
|
|
|
|
|
|
|
## Delete all print jobs
|
2023-10-05 13:11:38 -04:00
|
|
|
Write-Output "Deleting all print jobs from ""${Env:WINDIR}\System32\spool\PRINTERS"""
|
2021-06-02 16:16:24 -04:00
|
|
|
Try { Remove-Item "${Env:WINDIR}\System32\spool\PRINTERS\*" -Recurse }
|
2023-10-05 13:17:18 -04:00
|
|
|
Catch { Write-Error $_.Exception.Message }
|
2021-06-02 16:16:24 -04:00
|
|
|
|
|
|
|
|
## Start the spooler service
|
|
|
|
|
Control-Service -Start -Name $SERVICE
|
|
|
|
|
|
|
|
|
|
}
|