finally I use this script:
$allTask=$args[0]
$sleeptime=$args[1]
while (($allTask | where {$_.State -eq "running"}).count -gt 0) {
$i=0
$temp=@()
while ($i -le $allTask.Count){
$temp = $temp + (Get-Task | where {$_.Id -match $allTask[$i].Id})
$i++
}
$allTask=$temp
Sleep -s $sleeptime
}