I have a report that works like this:
get-vm | select name, memorygb,
@{N="GuestOS";E={$_.ExtensionData.Guest.guestFullName}}
What I would like to do is create a custom properties for each virtual disk on the VM. The first custom property shows the name of the virtual disk, the second one whether it is thin or thick provisioned. Some VMs have only one virtual disk. Others have 2,3 or 4.
How can I do this?
Thanks!
Try something like this
foreach($vm in Get-VM){
$obj = [ordered]@{
Name = $vm.Name
MemoryGB = $vm.MemoryGB
GuestOS = $vm.ExtensionData.Guest.guestFullName
}
$i = 1
Get-HardDisk -VM $vm | %{
$obj.Add("HD$($i)Name",$_.Name)
$obj.Add("HD$($i)Type",$_.StorageFormat)
$i++
}
New-Object PSObject -Property $obj
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
foreach($vm in Get-VM){
$obj = [ordered]@{
Name = $vm.Name
MemoryGB = $vm.MemoryGB
GuestOS = $vm.ExtensionData.Guest.guestFullName
}
$i = 1
Get-HardDisk -VM $vm | %{
$obj.Add("HD$($i)Name",$_.Name)
$obj.Add("HD$($i)Type",$_.StorageFormat)
$i++
}
New-Object PSObject -Property $obj
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ok great - thanks again