I\'ve got a file containing some data in PowerShell Object Notation:
@{ X = \'x\'; Y = \'y\' }
I\'d like to load this into a variable from
I ran into trouble using ConvertFrom-StringData as @Chad suggested. If you do:
$hash = get-content .\test.txt | ConvertFrom-StringData
I found I had an object array rather than a hash table. In fact, it appears that I had an array of hash tables, each with one entry. I confirmed with a:
$hash.GetType()
It looks like you need to join each line of the slurped input file to ensure that it forms a single string for ConvertFrom..'s use:
$hash = ((get-content .\test.txt) -join '`n') | ConvertFrom-StringData