September 15th, 2013

PowerTip: Use PowerShell to Search a Hash Table

Doctor Scripto
Scripter

Summary: Quickly search a hash table in Windows PowerShell.

Hey, Scripting Guy! Question How can I easily search for information in a hash table full of data in Windows PowerShell?

Hey, Scripting Guy! Answer Plug in the name of a value, for example:

[array]$Hashtable=$NULL
$Hashtable+=@{Purple=54}
$Hashtable+=@{People=37}
$Hashtable+=@{Eater=78}

To find the value called People, add the name to the hash table variable:

$Hashtable.People

37

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback