Is there a way to convert a powershell string into a hashtable?

Question:

Is there is any way to tell powershell to construct a hashtable from a string that’s formatted using the normal syntax for creating hashtables inline?

For example, is there any way to do something like:

Answer:

Hmm, shortly after posting this I stumbled upon the answer. I just needed to use the “Invoke-Expression” command on the string.

Source:

Is there a way to convert a powershell string into a hashtable? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply