Tuesday, September 22, 2015

Get list of VHDs on a hyper-v host server

$VMs = Get-VM
$VHDs = @()
Foreach ($VM in $VMs)
{
  $HardDrives = $VM.HardDrives
  Foreach ($HardDrive in $HardDrives)
  {
    $VHDs += $HardDrive.path | Get-VHD
  }
}

$VHDs | Sort-Object Path  |  ft Path

Reference: http://windowsitpro.com/hyper-v/using-powershell-list-vhds-used-hyper-v-host 

No comments:

Post a Comment

There was an error in this gadget