Reputation: 5887
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.
Upvotes: 0
Views: 426
Reputation: 72630
You can use New-Variable
CmdLet to create a var in wich you compose the name dynamicaly.
PS C:\Temp> $a = "AV"
PS C:\Temp> $newV = New-Variable -Name ($a+"123") -Value (New-Object -ComObject InternetExplorer.Application)
PS C:\Temp> Get-Variable av123
Name Value
---- -----
AV123 System.__ComObject
Upvotes: 2