pipe output to the screen as well as to 'append' it to a variable.

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Wilfredo Perez Wilfredo Perez 1 year, 10 months ago.

  • Author
    Posts
  • #22239
    Profile photo of ian
    ian
    Participant

    I would like to be able to pipe output to the screen as well as to 'append' it to a variable.

    For example, for something like this:

    $result =@()
    $result += Invoke-Command -cn $servers -scriptblock { foo }

    I would like to be able to see on the screen the running output of

    Invoke-Command -cn $servers -scriptblock { foo }

    as well as capture each result to the $result variable.

  • #22242
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

    Try using the tee-object look here: https://technet.microsoft.com/en-us/library/hh849937.aspx

You must be logged in to reply to this topic.