Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 232869

Retrieving information from an embedded hash table

$
0
0

I know this should be simpler but I just don't know the syntax to retrieve specific keys and subkey entries.  My hope is to display the information within the hash tables to a table or any other format needed.

 

here is the current snippet.

 

$Disk = @{} 
ForEach ($vSCSIController in ($vmView.Config.Hardware.Device | Where {$_.DeviceInfo.Label -match "SCSI Controller"})){    #'Unit Number: ' + $vSCSIController | %{$_.UnitNumber}    ForEach ($vDiskDevice  in ($vmView.Config.Hardware.Device | Where {$_.ControllerKey -eq $vSCSIController.Key}))        {        $Label = $vDiskDevice.DeviceInfo | %{$_.Label}        [string]$BusNum = $vSCSIController | %{$_.BusNumber}        [string]$DiskDev = $vDiskDevice | %{$_.UnitNumber}        [string]$SCSIid = $BusNum + ":" + $DiskDev        $HD = Get-VM $VM | get-harddisk | where {$_.Name -eq $Label}        $ID = @{                "Label" = $Label            "CapGB" = [System.Math]::Round($HD.CapacityKB / 1MB, 2)            "Filename" = $HD.Filename            "StorageFormat" = $HD.StorageFormat            "ScsiID" = $SCSIID            }        $Disk.Add([string]($HD.Name),$ID)        }    }
#
#"Disk Name" + "`t" + "SCSI Bus" + "`t" + "Capacity in GB" + "`t" + "Filename" + "`t" + "StorageFormat"
#'==============================================================================================================='   
$Disk.keys

 

The $Disk.Keys is where I am needing the help.  How would I display all values if Label is "Hard Disk 10"? and in the order listed near the end of the snippet?


Viewing all articles
Browse latest Browse all 232869

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>