Piping to a script block

Welcome Forums General PowerShell Q&A Piping to a script block

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

 
Participant
2 years, 4 months ago.

  • Author
    Posts
  • #47399

    Participant
    Points: 0
    Rank: Member

    This code works but I don't understand why.

    Is this dot sourcing a script block or something else?

  • #47401

    Keymaster
    Points: 1,644
    Helping HandTeam Member
    Rank: Community Hero

    Yeah, it's essentially dot-sourcing a script block. Kinda. $_ represents the pipeline object being input to the script. Visually, I find it a poor practice – it isn't appreciably different from using ForEach-Object, and it's not as easy to understand.

  • #47481

    Participant
    Points: 0
    Rank: Member

    Yep. Confused me.

    Thanks.

The topic ‘Piping to a script block’ is closed to new replies.