PowerShell for Windows Admins

Jan 14 2014   12:24PM GMT

VM disk info

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

A question came into the forum about getting information on the virtual disks associated with particular Hyper-V virtual machines. Is a bit of a digging exercise but this gets the results:

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

Get the set of VMs and for each of them get the VMHardDisks associated with the machine. For each VMHardDisk get the VHD – this is where you find the data you need.

 

The size and file size are in bytes – its a simple matter to create calculated fields that divide by 1GB or percentages if you require

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: