Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

-PassThru as common parameter #19989

Copy link
Copy link
@iRon7

Description

@iRon7
Issue body actions

Summary of the new feature / enhancement

Why adding the -PassThru switch on a case-by-case bases like: #13713 Add -PassThru parameter to Set-Clipboard?
In my believe every (advanced) function/cmdlet that has a ValueFromPipeline input and no (success stream) pipeline output, should have (an easy standard way to implement)¹ a default -PassThru functionality.

    • any function/cmdlet that doesn't have an explicit custom -PassThru parameter defined, and/or
    • based on an explicit empty output definition [OutputType([System.Void])]
      (but I fear that the OutputType property isn't correctly inplemented in every cmdlet. Anyways a -redundant- common -PassThru won't harm anything)

Take e.g.: Powershell - Get IP Addresses for hostnames from File (more than 150K hostnames)

The Export-Csv appears not to support the -PassThru parameter:

Export-Csv: A parameter cannot be found that matches parameter name 'PassThru'.

But I see no reason why these cmdlets shouldn't have a -PassThru parameter.
Wishful thinking:

... | Export-Csv .\test.csv -PassThru | Format-Table

This purpose might avoid wrapping cmdlet pipelines

This will affect functions and cmdlets along with:

Get-command | Where-Object { $_.Parameters } | Where-Object {
    $_.Parameters.getEnumerator().Foreach{ $_ }.Value.Attributes.ValueFromPipeline -eq $True -and
    !$_.OutputType -and !($_.Parameters.get_Keys() -eq 'PassThru')
}

A automated -PassThru parameter might even be included in some very common cmdlets which basically makes a cmdlet as Tee-Object redundant:

Tee-Object -PassThru comment
Tee-Object -FilePath .\Test.log Out-File -PassThru -FilePath .\Test.log
Tee-Object -Variable MyVar Set-Variable -PassThru -Name MyVar already exists
(Tee-Object -Host) Out-Host -PassThru See: #19827
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.