Skip to content

Instantly share code, notes, and snippets.

@Bigtalljosh
Last active July 10, 2018 14:50
Show Gist options
  • Save Bigtalljosh/771a2c3fcf1e609179a8c8c5f0990c27 to your computer and use it in GitHub Desktop.
Save Bigtalljosh/771a2c3fcf1e609179a8c8c5f0990c27 to your computer and use it in GitHub Desktop.
function Convert-HashToString
{
param
(
[Parameter(Mandatory = $true)]
[System.Collections.Hashtable]
$Hash
)
$hashstr = "@{"
$keys = $Hash.keys
foreach ($key in $keys)
{
$v = $Hash[$key]
if ($key -match "\s")
{
$hashstr += "`"$key`"" + "=" + "`"$v`"" + ";"
}
else
{
$hashstr += $key + "=" + "`"$v`"" + ";"
}
}
$hashstr += "}"
return $hashstr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment