Skip to content

Instantly share code, notes, and snippets.

@ByronScottJones
Created February 17, 2021 18:52
Show Gist options
  • Save ByronScottJones/2bd4994bb9a6f23bfc44afd3a010b568 to your computer and use it in GitHub Desktop.
Save ByronScottJones/2bd4994bb9a6f23bfc44afd3a010b568 to your computer and use it in GitHub Desktop.
Powershell - Deep Clone of Hashtable
function Get-DeepClone
{
[cmdletbinding()]
param(
$InputObject
)
process
{
if($InputObject -is [hashtable]) {
$clone = @{}
foreach($key in $InputObject.keys)
{
$clone[$key] = Get-DeepClone $InputObject[$key]
}
return $clone
} else {
return $InputObject
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment