0

I have an array of objects with properties "IP" for storing an ip address and "LastAlive" for storing the date that the server last responded to a ping.

In order to fill the LastAlive properties I use the following function:

function Update-AliveStatus ($nodes)
{
    foreach ($node in $nodes)
    {
        $alive = Test-Connection $node.IP -Quiet -Count 2
        if ($alive -eq $true)
        {
            $node.LastAlive = (Get-Date)
        }
    }
    return $nodes
}

This works fine unless the list of IPs is long, in which case it takes ages to iterate through all of them. How can I modify the function to run the pings asynchronously and still return the filled array when all the pings are done?

2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.