Export (0) Print
Expand All
Expand Minimize

Converting VBScript's Array Function


Windows PowerShell


Definition: Returns a Variant containing an array..

Array

In VBScript it's pretty easy to create an array: all you have to do is dimension a variable as an array, or use the Array function to add multiple values to a variable. Believe it or not, in Windows PowerShell it’s even easier to create an array; all you have to do is assign multiple values to a variable, no special functions or methods are required. For example, this command assigns all the colors of the rainbow to a variable named $a:



$a = "red","orange","yellow","green","blue","indigo","violet"

When you run this command and then echo back the value of $a you should get the following:



red
orange
yellow
green
blue
indigo
violet


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft