Author Posts

January 10, 2014 at 1:47 pm

Hello, I am trying to create a script that lists all the virtual machines in a given hyper-v cluster, and it also needs to list the maximum and the current size of the virtual disks that are attached to each virtual machine.

I started by getting this line that lists all the virtual machines in a given cluster –
Get-ClusterGroup -Cluster "myclustername" | Where GroupType –EQ 'VirtualMachine' | Get-VM

But unfortunately it does not give me any info about the maximum and the current size of the virtual disks that are attached to each virtual machine.

Can anyone help me here?

January 14, 2014 at 7:57 am

Try this


Get-VM |
foreach {
$VMname = $psitem.Name
Get-VMHardDiskDrive -VMName $VMname |
foreach {
Get-VHD -Path $_.Path |
select @{N='VMname'; e={$VMName}}, Path, Size, FileSize
}
}