update to use Tools.ps1 functions

This commit is contained in:
2021-06-02 10:42:49 -04:00
parent da98f582a5
commit 9c45e6c8b6
+8 -20
View File
@@ -1,22 +1,10 @@
## 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
## Stop the spooler service
Control-Service -Stop -Name 'spooler'
## Wait a few seconds to make sure it's stopped
Start-Sleep -Seconds 5
}
## Delete all print jobs
LogMsg "Deleting all print jobs from ""${Env:WINDIR}\System32\spool\PRINTERS"""
Try { Remove-Item "${Env:WINDIR}\System32\spool\PRINTERS\*" -Recurse }
Catch { LogErr $_.Exception.Message }
## 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." }
## Start the spooler service
Control-Service -Start -Name 'spooler'