Powershell: Repair Vhdx

Repair-VHD -Path "C:\CorruptedVMs\server01.vhdx" -Path "D:\Backups\healthy_server01.vhdx" -Passthru

Optimize-VHD -Path "C:\VHDX\suspect.vhdx" -Mode Full If a differencing VHDX is corrupt and its parent is healthy: repair vhdx powershell

$fixedVHD = Repair-VHD -Path "E:\Corrupt\data.vhdx" -Path "F:\Backups\data_clean.vhdx" -Passthru $fixedVHD | Format-List * Repair-VHD -Path "C:\CorruptedVMs\server01

catch Write-Warning "Repair-VHD failed: $($_.Exception.Message)" Write-Host "Attempting mount + chkdsk recovery..." $mountResult = Mount-VHD -Path $VhdPath -ReadOnly -PassThru -ErrorAction SilentlyContinue if ($mountResult) $disk = Get-Disk -Number $mountResult.Number -ErrorAction SilentlyContinue if ($disk) Where-Object $_.DriveLetter if ($partition) $driveLetter = "$($partition.DriveLetter):" Write-Host "Running chkdsk on $driveLetter..." & chkdsk $driveLetter /f /r /x Dismount-VHD -Path $VhdPath Write-Host "Chkdsk completed. Attempt to remount VHDX manually to verify." repair vhdx powershell