Repair Vhdx Powershell ((better)) -
Repair-VHD -Path "C:\CorruptedVMs\server01.vhdx" -Path "D:\Backups\healthy_server01.vhdx" -Passthru
[Parameter(Mandatory=$false)] [string]$BackupPath = "$env:TEMP\vhdx_backup_$(Get-Date -Format 'yyyyMMdd_HHmmss').vhdx" ) if (-not (Get-Module -ListAvailable -Name Hyper-V)) Write-Error "Hyper-V PowerShell module is required." exit 1 repair vhdx powershell
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) $partition = $disk Repair-VHD -Path "C:\CorruptedVMs\server01