September 10th, 2014

PowerTip: Find Value from PowerShell Hash Table

Doctor Scripto
Scripter

Summary: Look up values from a Windows PowerShell hash table.

Hey, Scripting Guy! Question How can I look up a specific value that is associated with a specific key in a Windows PowerShell hash table?

Hey, Scripting Guy! Answer Use the Item method and supply the key, for example:

$hash = @{

   2 = "Removable disk"

   3="Fixed local disk"

   4="Network disk"

   5 = "Compact disk"}

 

$hash.Item(3)

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.