As I learn more about Powershell, I really appreciate the Power it holds.

One of those Powers is the Hashtable.  A variable of indescribable power.  I’ll try to bring you new users in with this.  It’s really cool. 🙂

Normally in Powershell you just define a variable like this.






Or possibly you’ve done an Array such as




A Hashtable is a lot like an Array, and yet completely NOTHING like an array.   Normally an Array I can do this.




and get the result of




But a Hashtable can have one extra piece into it.  I can Group various TYPES of information into one list.  Alphabetic, Numeric, SecureString… If you can store it in Powershell, you can store it in a Hashtable.  It’s almost a MINI database when you’re done. So normally I might have a few arrays like this.





But as a hashtable I can group all of this possibly dis-similar information together as one Group.   It’s done by using the @{} as part of the variable assignment and assigning a variable WITHIN that.  So I could rewrite all of this as.






And done like this I can now access them as





The situations where you may or may not want to utilize a Hashtable are up to you.  But it’s just another way information is accessed.   Even if you don’t heavily use this, understanding HOW the information is created and accessed can help YOU further in learning how to navigate data through Powershell.


“Tabled for your consideration…”

The Energized Tech