April 5th, 2016

PowerTip: Create a nested PowerShell custom object

Doctor Scripto
Scripter

Summary: Learn how to create a nested PowerShell custom object.

Hey, Scripting Guy! Question How do I create a nested PowerShell custom object to store layers (nested) of information?

Hey, Scripting Guy! Answer Use a hashtable with the PSCustomObject type accelerator, and specify PSCustomObject as the value to the Property Name (Key):

[PSCustomObject]@{ PropertyName = [PSCustomObject]@{ NestedPropertyName = ‘NestedPropertyValue’ } }

7610.Dr.ScriptoForTips

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.