Piping to a script block

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Matthew MacFarland Matthew MacFarland 2 months, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47399
    Profile photo of Matthew MacFarland
    Matthew MacFarland
    Participant

    This code works but I don't understand why.

    Is this dot sourcing a script block or something else?

    #47401
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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
    Profile photo of Matthew MacFarland
    Matthew MacFarland
    Participant

    Yep. Confused me.

    Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.