VMware Cloud Community
fsosson
Contributor
Contributor
Jump to solution

How to display VM specific disk size

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
fsosson
Contributor
Contributor
Jump to solution

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 Smiley Sad

Regards,

Fred

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
fsosson
Contributor
Contributor
Jump to solution

Thanks a million, that helps me a lot,

Fred

Reply
0 Kudos