$SERVICE = 'spooler'

## Make sure the service isn't disabled
If (! ($(Get-Service -Name 'spooler').StartType -eq "Disabled") ) {

    ## Stop the spooler service
    Control-Service -Stop -Name $SERVICE
    
    ## Delete all print jobs
    Write-Output "Deleting all print jobs from ""${Env:WINDIR}\System32\spool\PRINTERS"""
    Try { Remove-Item "${Env:WINDIR}\System32\spool\PRINTERS\*" -Recurse  }
    Catch { Write-Error $_.Exception.Message }
    
    ## Start the spooler service
    Control-Service -Start -Name $SERVICE

}
