{"id":77663,"date":"2016-04-05T00:01:45","date_gmt":"2016-04-05T07:01:45","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=77663"},"modified":"2019-02-18T09:10:51","modified_gmt":"2019-02-18T16:10:51","slug":"powertip-create-a-nested-powershell-custom-object","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-create-a-nested-powershell-custom-object\/","title":{"rendered":"PowerTip: Create a nested PowerShell custom object"},"content":{"rendered":"<p><strong>Summary<\/strong>: Learn how to create a nested PowerShell custom object.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>\u00a0How do I create a nested PowerShell custom object to store layers (nested) of information?<\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/> Use a hashtable with the <strong>PSCustomObject<\/strong> type accelerator, and specify <strong>PSCustomObject<\/strong> as the value to the Property Name (Key):<\/p>\n<p style=\"padding-left: 90px\">[PSCustomObject]@{\nPropertyName = [PSCustomObject]@{ NestedPropertyName = \u2018NestedPropertyValue\u2019 }\n}<\/p>\n<p style=\"padding-left: 30px\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr_.ScriptoForTips.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-77491\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr_.ScriptoForTips.jpg\" alt=\"7610.Dr.ScriptoForTips\" width=\"96\" height=\"145\" \/><\/a><\/p>\n<p style=\"padding-left: 30px\">\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to create a nested PowerShell custom object. \u00a0How do I create a nested PowerShell custom object to store layers (nested) of information? Use a hashtable with the PSCustomObject type accelerator, and specify PSCustomObject as the value to the Property Name (Key): [PSCustomObject]@{ PropertyName = [PSCustomObject]@{ NestedPropertyName = \u2018NestedPropertyValue\u2019 } }<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[639],"tags":[327,356,3,45],"class_list":["post-77663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powertip","tag-brian-wilhite","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Learn how to create a nested PowerShell custom object. \u00a0How do I create a nested PowerShell custom object to store layers (nested) of information? Use a hashtable with the PSCustomObject type accelerator, and specify PSCustomObject as the value to the Property Name (Key): [PSCustomObject]@{ PropertyName = [PSCustomObject]@{ NestedPropertyName = \u2018NestedPropertyValue\u2019 } }<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/77663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=77663"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/77663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=77663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=77663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=77663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}