update to use Tools.ps1 functions
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user