Tip: Sometimes you need to restart the print spooler (workstation or server) to solve some issues.
Examples: job stuck, unable to cancel a job, printer not responding, etc.
To restart the print spooler service with PowerShell (as adminstrator):
1 2 3 4 5 6 |
# Local computer Restart-Service -Name Spooler -Force # Remote computer Restart-Service -InputObject $(Get-Service -ComputerName $computer -Name spooler) -Force Invoke-Command -ComputerName $computer {Restart-Service -Name Spooler -Force} |
Sometimes, restarting the print spooler service is not enough and you need to clean the print spooler queue.
You can delete the files or just move them into another folder.
1 2 3 4 5 6 7 8 9 |
Stop-Service -Name Spooler -Force # To backup the files Move-Item -Path "$env:SystemRoot\System32\spool\PRINTERS\*.*" -Destination 'C:\demo\new' -Force # To delete the files Remove-Item -Path "$env:SystemRoot\System32\spool\PRINTERS\*.*" Start-Service -Name Spooler |
Pingback: Powershell Tip #39: Easier way to define parameter attributes | Powershell Guru
Pingback: Powershell Tip #41: DefaultParameterSetName of the CmdletBinding attribute | Powershell Guru
PS C:\Windows\system32> Restart-Service -InputObject $(Get-Service -ComputerName phyl4143.polyclinic.pri -Name spooler) -Force
Invoke-Command -ComputerName phyl4143.polyclinic.pri {Restart-Service -Name Spooler -Force}
[phyl4143.polyclinic.pri] Connecting to remote server failed with the following error message : The WinRM client cannot complete the operation within the time specified. Check if the machine name is valid and is reachable over the network and firewall excepti
on for Windows Remote Management service is enabled. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (:) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionStateBroken
Im not quite sure what to do with this info, wrm is enabled.