Get and repair VHD Fragmentation on Hyper-V with PowerShell


From your Hyper-V host, you can see how much your VHDs are fragemented :

Get-VM | Get-VMHardDiskDrive | Get-VHD | Select-Object Path,VhdFormat,VhdType,FragmentationPercentage


If you want to defragment them, you an use Optimize-VHD or you can Live Storage Migration :

Optimize-VHD -Path "C:VMClient1Virtual Hard DisksClient1.vhdx"
Move-VMStorage -VMName Client1 -DestinationStoragePath D:VM

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.