Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Out-Printer

Out-Printer - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Send the output to a printer


-name string
        The printer name, if omitted will go to default printer.
   -inputObject psobject
        The object to be sent to the printer {may be piped}

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Print a text file:

PS C:\>get-content $pshome\ | Out-Printer

Print "Hello, World" to a specific printer:

PS C:\>"Hello, World" | out-printer "\\Server64\Prn86754"

Send the content of a variable to the default printer:

PS C:\> $myhelp = get-help -detailed get-wmiobject
out-printer -inputobject $myhelp

Cancel print Jobs:

PS C:\>Get-WmiObject Win32_Printer -computerName "Server64" | Where {$_.Name -eq "My Printer"} | ForEach { $_.CancelAllJobs() }

Print a file from Microsoft Word (which can apply formatting changes)

$WordObj=New-Object -ComObject Word.Application
$WordObj.Documents.Add('C:\test.txt') > $null
$WordObj.ActiveDocument.Content.Font.Size = 12
$WordObj.ActiveDocument.Content.Font.Name = "Verdana"

#Send To Default Printer

#Close File without saving