Created
November 26, 2022 17:31
-
-
Save codaamok/edeea9258f6111c80082b21faa36f018 to your computer and use it in GitHub Desktop.
PowerShell max depth for serialising data objects into child scopes. Execute this and observe how data is progressively lost while PowerShell serialises the object into the scopes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$xml = [xml]"<parent><child name='Adam'><grandchild name='Charlie'></grandchild></child></parent>" | |
$xml.parent | |
$xml.parent.child | |
$xml.parent.child.grandchild | |
Invoke-Command -ComputerName 'hostname' -ArgumentList $xml.parent -ScriptBlock { | |
param($xml) | |
$xml.child | |
$xml.grandchild | |
} | |
Invoke-Command -ComputerName 'hostname' -ArgumentList $xml.parent, (Get-Credential) -ScriptBlock { | |
param($xml, $cred) | |
Invoke-Command -VMName 'vmname' -Credential $cred -ArgumentList $xml -ScriptBlock { | |
param($xml) | |
$xml.child | |
$xml.grandparent | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment