Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Create Array in PowerShell

$
0
0

Summary: Use Windows PowerShell to easily create an array.

Hey, Scripting Guy! Question Can I use Windows PowerShell to create an array of strings and avoid typing quotation marks
           around all the strings?

Hey, Scripting Guy! Answer Instead of creating an array, such as this: $array = “a”,”b”,”c”,”d”,”e”,”f”,”g”,”h”, use a single string,
           and split it at the comma. It will be much less typing, and a whole lot faster. Here is an example:

$array = 'a,b,c,d,e,f,g,h'.Split(',')


Viewing all articles
Browse latest Browse all 3333

Trending Articles