Get Storage Drives Info for ALL VM's in a Given Cluster

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Richard Siddaway Richard Siddaway 3 years, 5 months ago.

  • Author
    Posts
  • #12490
    Profile photo of girakul
    girakul
    Participant

    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?

  • #12528
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    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
    }
    }

You must be logged in to reply to this topic.