Chapter 11. Grouping Data Using Arrays and Hash Tables

In This Chapter

  • Exploring arrays

  • Making and using arrays

  • Resizing arrays

  • Making multidimensional arrays

  • Examining other uses for arrays

  • Using hash tables

People naturally try to group similar things, whether those things are shapes, patterns, objects, or even abstract thoughts. Perhaps grouping is our way of creating order in a world that naturally wants to fall apart. To take off my philosopher's hat for a second, grouping things makes sense for some very obvious reasons. For one thing, groups allow you to organize a large number of items in manageable units. An additional benefit is that you can refer to a group of items by a single name rather than having to know the name of each individual item. Arrays are one way you can group data elements in Windows PowerShell, and hash tables provide an efficient way to store data elements by using name/value pairs.

In this chapter, you use arrays and hash tables to group data elements together into a manageable structure rather than just having a variable for each value you want to store. Arrays and hash tables are some of the most effective and widely-used ways for organizing large groups of related data, and you'll see these concepts used repeatedly within this book and in many of the scripts you'll find out there.

Taking an In-Depth Look at Arrays

An array is a structure for organizing data sequentially in which each element is accessed via an index value. In practice, you use arrays whenever ...

Get Windows PowerShell™ 2 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.