Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Re: Creating array

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 12-27-2007   #1 (permalink)
M Simmons
Guest


 

Re: Creating array

Arrays in Powershell are great, since they are determined to be an array at
the time that the variable is populated.

In short, you don't have to do anything different. Based on the
information you've provided:

$names = "test1","test2","test3"

Creates an array called "$names", and populates elements 0 through 2. you
can reference the elements in the array like this:

$names[0] (produces "test1")
$names[1] (produces "test2")

etc.

To enumerate through them, you could do something like:

foreach ($name in $names) {$name}

and it will output:

test1
test2
test3

Hope this helped.

_M_Simmons_


"Rajeev" <s.rajeev3@xxxxxx> wrote in message
news:63fe9261-b259-490d-9606-4bd28f88a5af@xxxxxx
Quote:

> Hello everyone,
>
> I'm new for power shell scripting. Can anyone guide how to create an
> array, here's the scenario
>
> I want to create a array of names
>
> test , test1, test2
>
> and i want to substitute these values for a variable $name
>
> for the first time $name should be test ($name = test)
> next it should be test1 ($name = test1)
> next it should be test2 ($name = test2)
>
> Hope this is clear. Any help is highly appreciated.

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Creating array Shay Levi PowerShell 2 12-26-2007 01:31 PM
Re: Creating array Shay Levi PowerShell 0 12-26-2007 07:41 AM
Re: Creating array Shay Levi PowerShell 0 12-26-2007 07:23 AM
Creating a byte array Thomas Lee PowerShell 5 03-06-2007 03:30 AM
Creating an array Marco Shaw PowerShell 1 11-07-2006 10:20 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com 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 2005-2008