Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Printing from PowerShell

Posted on June 6, 2006October 16, 2009

PowerShell has a slick feature that allows you to send the output from a cmdlet or expression directly to a printer. Pipe the output to the Out-Printer cmdlet and it will print out on the default printer:

get-process | out-printer

If you have other printers installed you can use the printer name. For example, I have Adobe Acrobat installed which installs a virtual printer. I can send the output of a command to that printer and generate a pdf:

get-service |where {$_.status -eq "stopped"} |out-printer "Adobe PDF"

If you want to print to a network printer, specify the printer UNC:

get-service |where {$_.status -eq "stopped"} |out-printer "\\Print01\HPLaserJ"

(By the way, you don't have to wrap the printer name in quotes, but I find it a good practice to avoid any confusion, especially when the printer name might have quotes.)

This is also a quick way to print the contents of text files directly from within PowerShell:

get-content c:\boot.ini |out-printer "\\Print01\hplaserj"

There's no page numbering or formatting options but it is a quick way to get a hard copy of you results.

Technorati Tags:
PowerShell
Scripting

Share this:

  • Print (Opens in new window) Print

Like this:

Like Loading…

Related

1 thought on “Printing from PowerShell”

  1. Hotel key card printing says:
    July 21, 2008 at 7:34 am

    Hi,

    It seems to be a good feature from PowerShell.

Comments are closed.

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2026 The Lonely Administrator | Powered by SuperbThemes!
%d