Hi,
In order to check whether some processes have completed or not, I created a foreach loop as follows:
$sources=@("Source1","Source2","Source3","Source4","Source5","Source6","Source7","Source8","Source9","Source10","Source11","Source12","Source13","Source14","Source15","Source16");
foreach($source in $sources){
# check whether timer job has completed or not
do{
Write-Host "Processing " $source
Start-Sleep 480
# Get new reference to the process, i.e.
# $process = Get-xxxxxx -Name $source
}
while ($process.NotCompleted)
$process = $null;
}It was working fine until Source11 (took about 16 hours). After that, there is no output on the screen and it does not start Source12. I waited for quite sometime but nothing happened afterwards. Followings are the outputs:
Processing Source 10 Processing Source 11 Processing Source 11 Processing Source 11 Processing Source 11 Processing Source 11
Did anyone experience this kind of issue before? It seems that it "lost" the iterator -- would it be safe if I use "for(initialization; condition; repeat)" statement rather than foreach loop?
Thank you