PoshCode Archive  Artifact Content

Artifact 9ca047e0f128129b6f0de240214d5131f12614a4961c9b5a557c22e38d66b8fc:

  • File nested-hashtables.ps1 — part of check-in [321169a532] at 2018-06-10 14:00:55 on branch trunk — Example using objects… (user: smaug9 size: 1160)

# encoding: ascii
# api: powershell
# title: nested hashtables
# description: Example using objects…
# version: 0.1
# author: smaug9
# license: CC0
# x-poshcode-id: 5763
# x-archived: 2015-03-15T15:21:38
# x-published: 2015-03-02T20:19:00
#
#
$Array1 = New-Object -TypeName PSObject -Property @{
            ArrayName = "Array01"
            Controller01Name = "vHBA1"
            Controller01WWN = "foobarfoobarfoobar01"
            Controller02Name = "vHBA2"
            Controller02WWN = "foobarfoobarfoobar02"        
        }

$Array2 = New-Object -TypeName PSObject -Property @{
            ArrayName = "Array02"
            Controller01Name = "vHBA1"
            Controller01WWN = "foobarfoobarfoobar01"
            Controller02Name = "vHBA2"
            Controller02WWN = "foobarfoobarfoobar02"
        }

$FabricA = @{
    SwitchIP = "1.2.3.4"
    VsanID = "Vsan01"
    ZoneSetname = "FabricA"
    Arrays = $Array1, $Array2
}

$FabricA.Arrays | Where {$_.arrayname -like '*01'}

# Many other examples here http://social.technet.microsoft.com/wiki/contents/articles/7804.powershell-creating-custom-objects.aspx