December 27th, 2013

PowerTip: Use PowerShell to Create Hash Table

Doctor Scripto
Scripter

Summary: Use a Windows PowerShell cmdlet to create a hash table.

Hey, Scripting Guy! Question How can I use Windows PowerShell to create a hash table if do not remember the special syntax?

Hey, Scripting Guy! Answer Use the ConvertFrom-StringData cmdlet, and put each key-value pair on its own line. 
          (You can perform this on a single line by using backtick character plus n (`n) for a new line):

PS C:\> convertfrom-stringdata "a=1`nb=2`nc=3"

Name                           Value

—-                           —–

c                              3

a                              1

b                              2

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