This is hopefully a very simple problem but with my limited knowledge of Powershell and Powercli, it is difficult for me. I am trying to produce a csv file with lot of information about our VMs. One of the piece is hard disk path and capacity. It is available using VMGuest.disks property. Since, I want to display all disk information in one column, I use following to put information in one field called diskinfo.
$DiskArr = $VMGuest.Disks | Select @{Name="DiskInfo";Expression={$_.path + " -- " + $_.CapacityGB }}
What I was hoping is that
$DiskArr -join ","
will give me result like c:\ -- 50.xxxxx GB, D:\ -- 32.000 GB and so on. But it gives me blanks with comma separated like ,,,, for four disks.
What am I missing?
The answer was provided in comments by Ben H. I am merely copying his answer:
$DiskArr -join ","
was changed to
$DiskArr.DiskInfo -join ","
Essentially problem was missing property name. I was providing object but without any property reference.