Skip to content

Latest commit

 

History

History
117 lines (84 loc) · 3.82 KB

Copy-ObjectGraph.md

File metadata and controls

117 lines (84 loc) · 3.82 KB

Copy-ObjectGraph

Copy object graph

Syntax

Copy-ObjectGraph
    -InputObject <Object>
    [-ListAs <Object>]
    [-MapAs <Object>]
    [-ExcludeLeafs]
    [-MaxDepth <Int32> = [PSNode]::DefaultMaxDepth]
    [<CommonParameters>]

Description

Recursively ("deep") copies a object graph.

Examples

Example 1: Deep copy a complete object graph into a new object graph

$NewObjectGraph = Copy-ObjectGraph $ObjectGraph

Example 2: Copy (convert) an object graph using common PowerShell arrays and PSCustomObjects

$PSObject = Copy-ObjectGraph $Object -ListAs [Array] -DictionaryAs PSCustomObject

Example 3: Convert a Json string to an object graph with (case insensitive) ordered dictionaries

$PSObject = $Json | ConvertFrom-Json | Copy-ObjectGraph -DictionaryAs ([Ordered]@{})

Parameters

The input object that will be recursively copied.

Type:Object
Mandatory:True
Position:Named
Default value:
Accept pipeline input:False
Accept wildcard characters:False

If supplied, lists will be converted to the given type (or type of the supplied object example).

Type:Object
Mandatory:False
Position:Named
Default value:
Accept pipeline input:False
Accept wildcard characters:False
Type:Object
Mandatory:False
Position:Named
Default value:
Accept pipeline input:False
Accept wildcard characters:False

If supplied, only the structure (lists, dictionaries, PSCustomObject types and Component types will be copied. If omitted, each leaf will be shallow copied

Type:SwitchParameter
Mandatory:False
Position:Named
Default value:
Accept pipeline input:False
Accept wildcard characters:False
Type:Int32
Mandatory:False
Position:Named
Default value:[PSNode]::DefaultMaxDepth
Accept pipeline input:False
Accept wildcard characters:False

Related Links