How it is possible to create a object and numbering it?
I want to run a loop and create objects with different names.
$url = "http://stackoverflow.com"
$n = 30
for($i = 0 ; $i -le $n; $i++)
{
($ie +$i) = New-Object -ComObject InternetExplorer.Application
($ie +$i).visible = $true
($ie +$i).Navigate($url)
}
So that the results are the objects:
$ie1 $ie2 $ie3 etc.
New-Variable, but why don't you create an array of objects? You could then access the individual objects with$ie[0],$ie[1], etc. This makes it easier to iterate through all of the objects (eg. to close all instances of Internet explorer:$ie| foreach { $_.Quit() })