Skip to content

Bring back Out-Printer #10660

Closed
Closed

Description

Summary of the new feature/enhancement

'As a user I want to be able to send output of a command to a printer.'
For example Get-Process | out-printer "OneNote"
would save the current processes to a new page in OneNote
or Get-Package | lp
Would send a list packages to the default printer

Proposed technical implementation details

Windows PowerShell has an Out-Printer command with an alias of lp .
but this was dropped in PowerShell core V6
I have posted a version for V6 and later at https://www.powershellgallery.com/packages/6print with a repo at https://github.com/jhoneill/6Print

This provides some additional controls over the output.
I'd propose this as a first draft / worked example of how it could be done.

Activity

  1. added
    Issue-Enhancement
    on Oct 1, 2019
  2. vexx32 commented on Oct 1, 2019

    @vexx32
    Collaborator

    Hmm, looks like that's using System.Drawing. have you tested it on Unix? In my own experience, a vast majority of System.Drawing APIs are not functional on Unix OSes, frequently throwing exceptions.

  3. jhoneill commented on Oct 1, 2019

    @jhoneill
    Author

    Rain Sallow (/u/ta11ow) (@vexx32) I should have said this is only restoring functionality from Windows PowerShell to Windows.
    This is fairly consistent, there is PrintManagement module which is Windows only. On Windows PS V6 and V7 can manage printers and print jobs but not submit a job to a printer.

    On Linux one should be able to use | lp and use the built in command.

  4. iSazonov commented on Oct 1, 2019

    @iSazonov
    Collaborator

    Previously the cmdlet was rejected as not ported. It is common rule that cmdlets in the repo should be ported. It would be great if you could implement ported version of the cmdlet.

  5. jhoneill commented on Oct 1, 2019

    @jhoneill
    Author

    Ilya (@iSazonov) If by "ported" you mean "in C# not PS" the repo has both the original PS version, and the C# version which is currently on the PowerShell gallery. It's probably a sign I should rearrange the repo :-)

  6. iSazonov commented on Oct 2, 2019

    @iSazonov
    Collaborator

    If by "ported" you mean "in C# not PS"

    No, I mean that the cmdlet should work on all supported OSes. See #10340.

  7. jhoneill commented on Oct 2, 2019

    @jhoneill
    Author

    Ilya (@iSazonov) Yes. Completely agree, cmdlets should work on all supported OSes, but this a should, not a must. We already have a Printer Management module which manages printer drivers, settings, queues and jobs (and it might make sense to out Out-Printer to this module). But this module only understands Windows print-devices, print-queues and print-jobs; Unix-based OSes have their own command line tools for managing these, Windows didn't have until PowerShell added them (and the "Print" command which has been around since DOS, is still in CMD but only sends a printer ready file to a port name like "PRN" or "LPT2" so is effectively "broken") .

    • My understanding of Linux isn't the best but AIUI you can docommand | lp and send Output to the printer.
    • Windows PowerShell 5 has Out-Printer with an alias of lp so you can do command | lp and send Output to the printer.
    • The only place where command | lp doesn't work is on PowerShell core when running on Windows.

    The idea is to plug that gap. Having something missing from some OSes is undesirable, but having something which was in Windows PowerShell 5 missing in 7 is probably worse - especially as any linux shell, including pwsh can print using | lp , which is their solution until the .NET portable subset gets printing support.

  8. iSazonov commented on Oct 2, 2019

    @iSazonov
    Collaborator

    Michael Klement (@mklement0) Can you advice how better resolve this? Can we use the same way as you suggest for clipboard and call a native command (lp?) on Linux? MacOS(lp?)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-EnhancementResolution-FixedWG-Cmdlets

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions