Skip to content

Provide support for cmdlets to stop the pipeline input gracefully #6070

Closed

Description

Currently, the only method a cmdlet has for stopping pipeline input is to throw an exception. However, doing so loses output that the cmdlet may have written.

In contrast, built in cmdlets have this capability. For example, Select-Object -First is able to cancel processing of subsequent input objects when the number of objects specified by -First is met.

In many cases, the limitation can be addressed by simply placing a Select-Object statement at the end of the pipeline but only if the constraint is a count of objects. In the cases where the constraint is not a simple count of objects, there is no direct method for accomplishing the same result.

This enhancement proposes providing the same capability to external managed and script-based cmdlets.

NOTE: Select-Object cancels pipeline input by throwing the internal exception StopUpstreamCommandsException. A simple solution would be to mark this exception as public or provide a static method that encapsulates it.

Activity

  1. iSazonov commented on Jan 31, 2018

    @iSazonov
    Collaborator

    Dup #3821

  2. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  3. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  4. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions