Skip to content

Instantly share code, notes, and snippets.

@trondhindenes
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trondhindenes/ac5b77b22fe422cb8885 to your computer and use it in GitHub Desktop.
Save trondhindenes/ac5b77b22fe422cb8885 to your computer and use it in GitHub Desktop.
#A hashtable converted into a json string can be converted back to hashtable like so:
#Create a hashtable, convert to json
$hash = @{"Name1"="Value";"Name2"="Value2"}
$json = $hash | ConvertTo-Json
#Take the json string and convert it back:
$newobject = $json | ConvertFrom-Json
$newhash = @{}
foreach ($prop in $newobject.psobject.Properties)
{
Write-verbose "added property $($prop.name) with value $($paramobject.($prop.name))"
$newhash.Add($prop.name,$newobject.($prop.name))
}
$newhash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment