Hi,
I am trying to write some line to display VM disk 2 size with Get-VM and Get-View without success.
Can someone help me to better understand the way those two command can help me to display hard disk information?
Thanks a lot,
Regards,
Frederic
You can but you will have to fetch all the required properties yourself.
Something like this
foreach($vm in (Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device)){
$vm.Config.Hardware.Device |
where{$_ -is [VMware.Vim.VirtualDisk] -and $_.DeviceInfo.Label -eq 'Hard disk 2'} |
Select @{N='VM';E={$vm.Name}},
@{N='Label';E={$_.DeviceInfo.Label}},
@{N='CapacityGB';E={[math]::Round($_.CapacityInKB/1MB,0)}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not sure exactly what you want to report on.
But is this producing what you are looking for ?
Get-VM -Name MyVM | Get-HardDisk -Name 'Hard disk 2'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
It produces what I was looking for but I was talking about get-view because I would like to align the output with memory configuration. This where I am lost about the way to extract information
Regards,
Fred
You can but you will have to fetch all the required properties yourself.
Something like this
foreach($vm in (Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device)){
$vm.Config.Hardware.Device |
where{$_ -is [VMware.Vim.VirtualDisk] -and $_.DeviceInfo.Label -eq 'Hard disk 2'} |
Select @{N='VM';E={$vm.Name}},
@{N='Label';E={$_.DeviceInfo.Label}},
@{N='CapacityGB';E={[math]::Round($_.CapacityInKB/1MB,0)}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a million, that helps me a lot,
Fred