Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
The "Out-Printer" cmdlet is a PowerShell command used to send output directly to a printer. However, this cmdlet is not applicable in the Windows environment as it is specific to PowerShell on Windows Server and Windows 10/11. Instead, Windows offers several powerful tools and cmdlets to manage print queues and printers effectively. This article will guide you through using PowerShell to manage print queues, add printers, and troubleshoot printing issues on a Windows machine.
Examples:
Listing All Printers:
To list all printers installed on your Windows machine, you can use the Get-Printer
cmdlet.
Get-Printer
Adding a New Printer:
To add a new printer, use the Add-Printer
cmdlet. Here’s an example of adding a network printer.
Add-Printer -Name "OfficePrinter" -DriverName "HP Universal Printing PCL 6" -PortName "IP_192.168.1.100"
Removing a Printer:
To remove a printer, use the Remove-Printer
cmdlet.
Remove-Printer -Name "OfficePrinter"
Printing a Test Page:
To print a test page, you can use the Invoke-Expression
cmdlet to call the rundll32
command.
Invoke-Expression -Command "rundll32 printui.dll,PrintUIEntry /k /n \"OfficePrinter\""
Managing Print Queues:
To list all print jobs in a specific printer’s queue, use the Get-PrintJob
cmdlet.
Get-PrintJob -PrinterName "OfficePrinter"
Removing a Print Job:
To remove a specific print job, use the Remove-PrintJob
cmdlet.
Remove-PrintJob -PrinterName "OfficePrinter" -ID 12
Setting Default Printer:
To set a default printer, use the Set-PrintConfiguration
cmdlet.
Set-PrintConfiguration -PrinterName "OfficePrinter" -Default
Troubleshooting Printer Issues:
To troubleshoot printer issues, you can use the Get-EventLog
cmdlet to check for any related errors in the event logs.
Get-EventLog -LogName System -Source PrintService