Passing data along pipeline

Welcome Forums General PowerShell Q&A Passing data along pipeline

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 9 months ago.

  • Author
  • #23136

    Points: 1
    Rank: Member

    I have a command I run within a pipeline that receives a sequence of computer names. How can I amend that command so that after it I can pipe to select and get the original computer name and whatever it added?


  • #23137

    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    The command would need to output a custom object that included whatever information you want. Or, take whatever object it's currently outputting, and use Add-Member to add a ComputerName property to that. It's a little hard to be more specific without seeing some of the actual code, but Learn PowerShell Toolmaking in a Month of Lunches is pretty much crammed with what you're asking for.

  • #23166

    Points: 1
    Rank: Member

    Ahh, you got me sorted.

    Piping the first command into `Add-Member -Type NoteProperty -Name PropName -Value $VarToAdd -PassThru` and continuing on got me what I needed.

    Much appreciated!

The topic ‘Passing data along pipeline’ is closed to new replies.