Private/Copy-Hashtable.ps1
# Copyright 2019 David Haymond. # # This Source Code Form is subject to the terms of the Mozilla Public License, # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at https://mozilla.org/MPL/2.0/. function Copy-Hashtable { [CmdletBinding()] [OutputType([hashtable])] param( [Parameter( Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] $InputObject ) process { if ($InputObject -is [hashtable]) { $clone = @{ } foreach ($key in $InputObject.Keys) { $clone[$key] = Copy-Hashtable -InputObject $InputObject[$key] } return $clone } else { return $InputObject } } } |