2012-08-15 2 views
1

foreach 루프를 사용하여 함께 5 .Responsetime's의 가치를 추가하지만 난 그게 동작하지 않습니다 :파워 쉘 : 간단한의 Foreach은 그래서 간단한에 노력하고있어

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 
} 

어떤 아이디어를 이동 ?

감사

당신은 대신 재 할당의 사용자 $의 금액을 증가해야

답변

2

:

$sum += $item.responsetime 
2
(test-connection www.google.com -count 5 | ` 
     Measure-Object -Property ResponseTime -sum).sum