How to Send to a Printer in PowerShell
Print from a Microsoft Windows PowerShell command line rather than opening and printing a file to save time if you are already working within a PowerShell command-line environment. The Windows PowerShell tool includes a cmdlet utility that can forward documents and typed text to the printer you specify when required. Use the out-printer cmdlet to print documents from PowerShell without using the GUI (Graphical User Interface).
Instructions
-
-
1
Click the "Start" button on the Windows 7 taskbar and select All Programs. Click Accessories. Click the Windows PowerShell folder and then select Windows PowerShell in the menu that appears.
-
2
Type "cd /directory_path_of_file_to_print/" at the command prompt, replacing "/directory_path_of_file_to_print/" with the actual path to the file you wish to print. (Don't include the quotation marks in this command.) Press the "Enter" key.
-
-
3
Enter "type my_document.txt | out-printer" on the command line, replacing "my_document.txt" with the name of a file you wish to print, and press the "Enter" key. The contents of the file will print to the Windows 7 computer default printer.
-
4
Type ""this is a test" | out-printer" at the command prompt and press the "Enter" key. The text typed inside the quotes (in this case "this is a test") will print to the default printer configured on the Windows 7 computer.
-
5
Enter "type my_file.txt | out-printer --name \\my_printer\" on the command line, replacing "my_file.txt" with the name of a file you wish to print and replacing "my_printer" with the name of a printer other than the Windows 7 computer default printer. Press the "Enter" key and the file specified will be printed to the printer named in the command line.
-
1
References
- Photo Credit Comstock Images/Comstock/Getty Images