THAT’S a freaking mouthful!

Let’s put that into plain ordinary English.   An array is a matrix of values.  Most of the time you have a Single level Array (One Column is how I remember it).  Something like this.


The other trick when creating these arrays is if the list is longer than the screen (which makes readability a pain).  You can also just break up the lines after each comma , like so.


This is far more readable, probably easier to count visually

So to access any of these values you would reference the position in the Array.   Say #4 for “Poodle” flavoured Jello.  Remembering of course that your arrays start at 0.



A MultiLevel Array array is actually multiple columns.   To create a MULTI level array you have to enclose each row within brackets ()

So a Multi-Leveled array would look like this.   The various sub levels can be Dynamic in size (Meaning they don’t all have to have the EXACT same amount of entries) which is part of the incredible Power in Windows Powershell


If you were to try accessing members of THIS array keying in


Would show you the list of “Pie” etc etc etc.   But since we have enclosed certain sets within Brackets they are treated as a SEPARATE array unto themselves


Would show you “Pie”.  While if you accessed


Would show you “Lemon”,”Apple” and “Chicken”.  But I can access the individual members of THAT array by specifying their position


Which shows “Chicken”.

Confused?  If I want to access the “Toad” part in “Deserts” (since I’ve decided that for some reason Frog just wasn’t on the menu) I can key in


Is you head spinning enough?  It get’s worse (or better depending on how you think) I can mix and match different types of variable IN these arrays.     But you might not do that.

The advantage to all of this is you can have a list of something where I am using this like Say Divisions in a company, And start matching up Security Groups by Division and Location.  Say I start with my organizational details like so.

$CompanyDetails=,(“New York”)

Now we can extend this to the Divisions from Each location.  Some may be larger than others.

$CompanyDetails=,(“New York”,(“Accounting”,”Management”,”AGotLost”))

Or some are a bit sillier

We could extend this that if a user was in a particular Company Location, they might have certain Security Groups to work as well.

$CompanyDetails=,(“New York”,
(“Tough Security”,”Really Tough”))

(“Better than NY”,”Look out”,”Whoops Not This Group”,”Domain Admins”))

(“Enterprise Admins”,”Fans of Powershell”))


So what you have now is an array that is 3 levels deep that you can easily build upon.   The TRICKY part in this equation is if you have to ADD to it.   So if I want to create a new entry within a specify point I have to reference the point directly and add to it. 

$CompanyDetails[2][1]+=,(“Another Stupid Security Group”)

Accessing that entry in the array will now have ANOTHER member


Another Stupid Security Group

Is this a perfect example? Probably not.  But hopefully it will give you a feel with how you can add and work with deeper arrays.   And yes.  If you go really over the top, you could build a really deep rabbit hole.

You are of course, best to store much of this information within an SQL database but sometimes we want to have the data localized to the Powershell script.

Remember, the Power of Shell is in YOU

The Energized Tech