Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Re: Creating array

Reply
 
Old 12-26-2007   #1 (permalink)
Shay Levi


 
 

Re: Creating array


You don't need the $name var, you can point -Name to the $array index:


$array = "test","test1","test2"

$i = 0
while ($i -le 1)
{
$vm = New-VM -Name $array[$i]
$i++
}



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> Thanks for the solution.
>
> I'm trying to implement this in the below loop (its uses a different
> library)
>
> $i = 0
> while ($i -le 1)
> {
> $vm = New-VM -Name $name
> $i++
> }
> I'm trying to substitute the $name with test & test1 when $i = 0 & 1
> respectively.
>
> can you guide me.
>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: Creating array PowerShell
Re: Creating array PowerShell
Re: Creating array PowerShell
Creating a byte array PowerShell
Creating an array PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46