control output remoting script

Welcome Forums General PowerShell Q&A control output remoting script

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

3 years, 4 months ago.

  • Author
  • #31261

    Points: 0
    Rank: Member

    i have a function that do a lot of tasks running remotely on multiple computers

    Function TASKS {....}
    ICM IPS ${Function:TASKS}

    the function work on each computer but I want to end the output of each task on my central console with:
    This task executed on: IP1
    This task executed on: IP2

    in other words.. is it possible to get IP from wich my task is executed.., when i used argumentlist parameter i have the same IP value on the output
    thank you

  • #31492

    Points: 0
    Rank: Member


    Any values that are output from your TASKS function as it runs on an individual remote machine will be received in the pipeline of the machine you're running from. That means you could add, for example Write-Output $env:COMPUTERNAME to the end of the code in the TASKS function, and then modify your Invoke-Command like this:

    ICM $IPS ${Function:TASKS} | ForEach-Object {
        Write-Host "This task executed on: $_"

    The reason I did it with the computer name instead of the IP is because it's easier. You can get the IP of the machine like this:

    (get-netadapter | get-netipaddress | ? addressfamily -eq 'IPv4').ipaddress

    Hope that helps!


  • #31514

    Points: 0
    Rank: Member

    thank you

The topic ‘control output remoting script’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort