{"id":808022,"date":"2026-05-13T11:00:54","date_gmt":"2026-05-13T11:00:54","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=808022"},"modified":"2026-05-13T11:00:54","modified_gmt":"2026-05-13T11:00:54","slug":"clear-print-queue-powershell-script","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/clear-print-queue-powershell-script\/","title":{"rendered":"Como usar o PowerShell para limpar filas de impress\u00e3o"},"content":{"rendered":"<p>Todos n\u00f3s dependemos de impressoras, seja no escrit\u00f3rio ou no trabalho remoto. No entanto, por mais essenciais que sejam, as impressoras \u00e0s vezes podem ser complicadas. Para os profissionais de TI e os <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">provedores de servi\u00e7os gerenciados (MSPs)<\/a>, manter a efici\u00eancia dos servidores de impress\u00e3o \u00e9 fundamental. Portanto, quando surgem problemas com a impressora, ter um m\u00e9todo eficaz para resolv\u00ea-los se torna inestim\u00e1vel.<\/p>\n<h2>Entendendo as filas de impress\u00e3o<\/h2>\n<p>Uma fila de impress\u00e3o \u00e9 uma \u00e1rea de armazenamento tempor\u00e1rio para trabalhos de impress\u00e3o que est\u00e3o esperando para serem impressos. Quando voc\u00ea envia um documento para uma impressora, ele n\u00e3o vai diretamente para o hardware da impressora. Em vez disso, ele primeiro encontra seu caminho para a fila de impress\u00e3o. A partir da\u00ed, a fila de impress\u00e3o gerencia com efici\u00eancia esses trabalhos, enviando-os para a impressora quando estiverem prontos.<\/p>\n<p>Entretanto, como qualquer sistema, a fila de impress\u00e3o pode apresentar problemas. Talvez um determinado trabalho fique preso, impedindo o processamento dos trabalhos subsequentes. Talvez uma impressora fique off-line, fazendo com que a fila se acumule. Essas interrup\u00e7\u00f5es podem causar atrasos e inefici\u00eancias operacionais.<\/p>\n<p>\u00c9 nesse ponto que o script do PowerShell discutido nesta postagem do blog se torna inestim\u00e1vel. Ele foi projetado para limpar todos os trabalhos da fila de impress\u00e3o, garantindo opera\u00e7\u00f5es de impress\u00e3o sem problemas. Para utilizar esse script, verifique se voc\u00ea tem privil\u00e9gios de administrador.<\/p>\n<h2>O roteiro<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Clears Print Queue for all printers\r\n.DESCRIPTION\r\n    Clears Print Queue for all printers.\r\n    This script will stop the printer spooler service, clear all print jobs, and start the printer spooler service.\r\n    If some print jobs are not cleared, then a reboot might be needed before running this script again.\r\n.EXAMPLE\r\n    No parameters needed\r\n.OUTPUTS\r\n    String\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes:\r\n    Initial Release\r\n    (c) 2023 NinjaOne\r\n    By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n.COMPONENT\r\n    Printer\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam ()\r\n\r\nbegin {\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n}\r\n\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n    Write-Host \"Stopping print spooler service\"\r\n    $StopProcess = Start-Process -FilePath \"C:WINDOWSsystem32net.exe\" -ArgumentList \"stop\", \"spooler\" -Wait -NoNewWindow -PassThru\r\n    # Exit Code 2 usually means the service is already stopped\r\n    if ($StopProcess.ExitCode -eq 0 -or $StopProcess.ExitCode -eq 2) {\r\n        Write-Host \"Stopped print spooler service\"\r\n        # Sleep just in case the spooler service is taking some time to stop\r\n        Start-Sleep -Seconds 10\r\n        Write-Host \"Clearing all print queues\"\r\n        Remove-Item -Path \"$env:SystemRootSystem32spoolPRINTERS*\" -Force -ErrorAction SilentlyContinue\r\n        Write-Host \"Cleared all print queues\"\r\n\r\n        Write-Host \"Starting print spooler service\"\r\n        $StartProcess = Start-Process -FilePath \"C:WINDOWSsystem32net.exe\" -ArgumentList \"start\", \"spooler\" -Wait -NoNewWindow -PassThru\r\n        if ($StartProcess.ExitCode -eq 0) {\r\n            Write-Host \"Started print spooler service\"\r\n        }\r\n        else {\r\n            Write-Host \"Could not start Print Spooler service. net start spooler returned exit code of $($StartProcess.ExitCode)\"\r\n            exit 1\r\n        }\r\n    }\r\n    else {\r\n        Write-Host \"Could not stop Print Spooler service. net stop spooler returned exit code of $($StopProcess.ExitCode)\"\r\n        exit 1\r\n    }\r\n    exit 0\r\n}\r\n\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Implica\u00e7\u00f5es de seguran\u00e7a do script<\/h2>\n<p>Embora esse script do PowerShell seja uma vantagem para o gerenciamento de filas de impress\u00e3o, \u00e9 essencial estar ciente de suas implica\u00e7\u00f5es de seguran\u00e7a:<\/p>\n<ol>\n<li><strong>Privil\u00e9gios de administrador:<\/strong> O script exige direitos de administrador, pois interage com servi\u00e7os de n\u00edvel de sistema, como o spooler de impress\u00e3o. Se voc\u00ea n\u00e3o for um administrador, n\u00e3o dever\u00e1 executar esse script.<\/li>\n<li><strong>Vulnerabilidades em potencial:<\/strong> Se n\u00e3o for devidamente protegido, agentes mal-intencionados poder\u00e3o explorar o script, excluindo trabalhos de impress\u00e3o ou at\u00e9 mesmo interrompendo servi\u00e7os. Certifique-se sempre de que o script seja proveniente de fontes confi\u00e1veis e seja mantido em locais seguros.<\/li>\n<li><strong>Consulta:<\/strong> Se voc\u00ea tiver alguma d\u00favida em rela\u00e7\u00e3o \u00e0 seguran\u00e7a do script, \u00e9 sempre aconselh\u00e1vel consultar um profissional de seguran\u00e7a de TI.<\/li>\n<\/ol>\n<h2>Outras dicas r\u00e1pidas para solucionar problemas com a impressora<\/h2>\n<p>Est\u00e1 tendo problemas com a impressora? Al\u00e9m de usar o script do PowerShell para limpar a fila de impress\u00e3o, aqui est\u00e3o algumas etapas gerais de solu\u00e7\u00e3o de problemas:<\/p>\n<ol>\n<li><strong>Verifica\u00e7\u00e3o de energia:<\/strong> Verifique se o cabo de alimenta\u00e7\u00e3o da impressora est\u00e1 conectado ao plugue e se o dispositivo est\u00e1 ligado.<\/li>\n<li><strong>Conectividade:<\/strong> Verifique novamente a conex\u00e3o da impressora com o computador.<\/li>\n<li><strong>P\u00e1gina de teste:<\/strong> Imprima uma p\u00e1gina de teste para confirmar se a impressora est\u00e1 funcionando corretamente.<\/li>\n<li><strong>Reiniciar:<\/strong> Em geral, uma simples reinicializa\u00e7\u00e3o do computador e da impressora pode resolver muitos problemas.<\/li>\n<li><strong>Suporte do fabricante:<\/strong> Se os problemas persistirem, considere entrar em contato com o fabricante da impressora para obter suporte dedicado.<\/li>\n<\/ol>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>No cen\u00e1rio din\u00e2mico da TI, as ferramentas que simplificam as opera\u00e7\u00f5es e resolvem problemas do mundo real s\u00e3o inestim\u00e1veis. Esse script do PowerShell para limpar a fila de impress\u00e3o \u00e9 uma dessas ferramentas, garantindo opera\u00e7\u00f5es de impress\u00e3o eficientes e sem problemas. Sempre aborde esses scripts com uma compreens\u00e3o de sua finalidade, benef\u00edcios e poss\u00edveis implica\u00e7\u00f5es.<\/p>\n","protected":false},"author":35,"featured_media":141950,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[12456],"class_list":["post-808022","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/808022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=808022"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/141950"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=808022"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=808022"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=808022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}