Я думаю, что было бы лучше проверить, если IE не был закрыт пользователем в какой-то момент, прежде чем пытаться перейти к следующему URL.Кроме того, $ie.name
является строкой, поэтому $ie.name -contains 'Internet Explorer'
будет неправильным.
Может быть, это работает лучше для вас.
function IEWeb {
# create an array with the urls you want to revolve
$urls = 'http://p-captas02.int.addom.dk/cap-tas-views/Queue.aspx',
'https://oneview.int.addom.dk/dashboard?dashboard_id=1',
'https://oneview.int.addom.dk/dashboard?time=0&scroll_value=15&dashboard_id=10'
$ie = New-Object -Comobject 'InternetExplorer.Application'
$ie.visible=$true
$index = 0
while ($ie.HWND) { # for as long as the user does not close IE
$ie.navigate($urls[$index])
Start-Sleep 15
# increment the array counter, and revert to index 0 if $urls length is reached
$index = ($index + 1) % $urls.Count
}
try {
# close and release the Com object from memory
$ie.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie) | Out-Null
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
}
catch {}
}
IEWeb