So I’m trying to simple add the value of 5 .Responsetime's together using a foreach loop but I can’t get it to work:
function go
{
$ping_cycle = test-connection -count 5 -computername www.google.com | select Responsetime
$sum = 0
foreach($item in $ping_cycle)
{
[void]$sum +$item.responsetime
}
$sum
}
go
Any Ideas?
Thanks
You have to increment your $sum instead of reassigning it :