About_Pipelines

Welcome Forums General PowerShell Q&A About_Pipelines

Viewing 8 reply threads
  • Author
    Posts
    • #240011
      Participant
      Topics: 8
      Replies: 13
      Points: 56
      Rank: Member

      Hello Team,

      Appreciate if someone could clear my confusion around pipeline ♥

      Says “when multiple objects are sent across |  being processed one at a time and sends to next cmdlet and so on … ”

      I guess it is more or else a sequential process. How come sort-object works to whole collection of objects if it is getting one object at a time?  

      When cmdlet param accepts input pipeline byValue of type <PSObject> ( single object, no [] )

      Is there a point to use ForEach-Object before using that cmd ? This again correlates to the above question, since pipeline process one-by-one .. So #3 from the below example is not necessary and skip it

    • #240044
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      I guess it is more or else a sequential process. How come sort-object works to whole collection of objects if it is getting one object at a time?

      There are certain cmdlets breaking with the rule of “one item at a time in the pipeline”. Otherwise they couldn’t work. That’s why they take more time to process usually.

      So #3 from the below example is not necessary and skip it

      Yes.

    • #240050
      js
      Participant
      Topics: 32
      Replies: 842
      Points: 2,690
      Helping Hand
      Rank: Community Hero

      Why is the text cut off on the right side? In powershell 5 you can test the hosts in parallel like:

      • #240179
        Participant
        Topics: 8
        Replies: 13
        Points: 56
        Rank: Member

        @JS,

        I’m just merely making a point, not to any specific cmdlet. I have seen coders using foreach-object in pipeline which doesn’t makes sense to me when cmdlet accepts input pipeline. Unless you have extra-doing in the process block I think you can ignore using  foreach

         

    • #240053
      js
      Participant
      Topics: 32
      Replies: 842
      Points: 2,690
      Helping Hand
      Rank: Community Hero

      Ack, I can’t even edit the last post. The edit is cut off.

    • #240068
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Ack, I can’t even edit the last post. The edit is cut off.

      It works for me on this thread but I had seen this in other threads already … you might post this in https://powershell.org/forums/forum/community-discussion-site-feedback/

    • #240209
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      I’m just merely making a point, not to any specific cmdlet. I have seen coders using foreach-object in pipeline which doesn’t makes sense to me when cmdlet accepts input pipeline. Unless you have extra-doing in the process block I think you can ignore using foreach

      You know that not all cmdlets support pipeline input, don’t you? And not all coders always write the best, most efficient and pure code following best practice rules. 😉

      It’s like Jeffrey Snover used to say: The world always has been, is and will always be – messy. 😀 Sometimes the only thing what counts is – the code runs without errors and does what it’s suppost to do.

    • #240431
      Participant
      Topics: 8
      Replies: 13
      Points: 56
      Rank: Member

      Yeah 😁..  well said 👍 

    • #243443
      Participant
      Topics: 8
      Replies: 13
      Points: 56
      Rank: Member

      Eg 1:

      Eg 2: Saved Below content to .\Test-InputPipe.ps1

      What’s the difference between Eg1 and Eg2 ?  I am trying to understand the pipeline functionality which seems hard to crack  apparently ☹

      • This reply was modified 2 months, 1 week ago by Harsha.
      • This reply was modified 2 months, 1 week ago by Harsha.
    • #243479
      Participant
      Topics: 8
      Replies: 13
      Points: 56
      Rank: Member

      I think I’ve found answer. Included the write-host statement in  process block of the script..

Viewing 8 reply threads
  • You must be logged in to reply to this topic.