Hashes

Hashes are used like arrays. The main difference is that they use the values as indexes versus sequentially numbered indexes. This provides easy functionality to add, remove, modify, and find data contained in the hash table. Hash tables are useful for static information that needs a direct correlation to other data:

Name

Value

John.Doe

Jdoe

Jane.Doe

jdoe1

A good example of a hash table would be in the instance of an Active Directory migration. In most Active Directory migrations, you would need to correlate old usernames to new usernames. The preceding table represents a username mapping table for these types of migrations. While a traditional array would work, a hash table makes this much easier to do.

To create the preceding ...

Get Mastering Windows PowerShell Scripting 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.