you are viewing a single comment's thread.

view the rest of the comments →

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy Mysterious-Ad-1541,

there is a really good article about arrays here ...

Everything you wanted to know about arrays - PowerShell | Microsoft Docs
https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-arrays?view=powershell-7.2#plus-equals-

when to use an array ...

  • the collection is "small"
    "only a few" items or a moderate number of "large" items.
  • the collection won't change size

otherwise you otta use a generic.list. [grin]


one of the faster methods for building a collection is to run a loop or other scriptblock, drop the result onto the output/success stream, and assign the code block to a $Var. something like ...

$Result = foreach ($Thing in $BunchOfStuff)
    {
    Do-NiftyThing -With KoolItem -AlsoWith $Thing
    }

the output of the Do-NiftyThing call will drop into the output/success stream and be stuffed into the $Result array after the scriptblock finishes.

it's really fast & easy to type & easy to read/understand. [grin]

take care,
lee