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

Welcome Forums General PowerShell Q&A 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

 
Participant
4 years, 11 months ago.

  • Author
    Posts
  • #12490

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

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

The topic ‘Get Storage Drives Info for ALL VM's in a Given Cluster’ is closed to new replies.