Skip to content

Instantly share code, notes, and snippets.

@timnew
Created April 13, 2012 04:56
Show Gist options
  • Save timnew/2373809 to your computer and use it in GitHub Desktop.
Save timnew/2373809 to your computer and use it in GitHub Desktop.
Powershell script to covert between hash and key value pairs
Function ConvertTo-KeyValue($hashObject) {
$hashObject.GetEnumerator() | %{ $_.Key + "=" + $_.Value }
}
Function ConvertTo-Hash($text) {
if($text -eq $null) {
$text = $input
}
$result = @{}
$text | %{
$parts = $_.Split("=", 2);
$result[$parts[0]] = $parts[1]
}
$result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment