title: PowerShell - adding a column to an array
body: <p>Let’s say you're doing something like this:</p>
  
  <pre><code>$partitions = get-wmiobject -query "Associators of {Win32_DiskDrive.DeviceID=""$DevID""} WHERE AssocClass = Win32_DiskDriveToDiskPartition" -computer $ComputerName
  </code></pre>
  
  <p>If you then want to get the disk caption for each disk (the 'C:') you need something like this:</p>
  
  <pre><code>function GetDiskCaption {
     param ($Partition, $ComputerName)
  
      $DeviceID = $Partition.DeviceID
      $colLogicalDisk = get-wmiobject -query "Associators of {Win32_DiskPartition.DeviceID=""$DeviceID""} WHERE AssocClass = Win32_LogicalDiskToPartition" -computer $ComputerName
  
     If ($colLogicalDisk.Caption -ne $null) {
        return $colLogicalDisk.Caption
     }
     Else {
         return "UNASSIGNED"
     }
  }
  </code></pre>
  
  <p>I'm not a very advanced PowerShell user, so the question is: What's the best PowerShell way to add the disk caption to the array so that can pipe it into, say, ft or some other script?</p>
  
  <p>Now I realise I can just do a foreach loop to print this out, but I want to work out how to extend an array with extra columns so that I can then use piping operators to, say, format the array.</p>
  
  <p>The examples on the Microsoft site on array handling are all based on one-dimensional arrays, so adding arrays does not seem to be the answer.</p>
  
  <p>I'm specifically trying to write a script to dump out the list of disks, with their iSCSI mapping (if any) and the various partitions on that disk.</p>