$fixedVHD = Repair-VHD -Path "E:\Corrupt\data.vhdx" -Path "F:\Backups\data_clean.vhdx" -Passthru $fixedVHD | Format-List *
[Parameter(Mandatory=$true)] [string]$HealthyCopyPath,
Optimize-VHD -Path "C:\VHDX\suspect.vhdx" -Mode Full If a differencing VHDX is corrupt and its parent is healthy:
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."
[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
# Recreate the differencing disk from healthy parent $parentPath = "D:\BaseImages\parent.vhdx" $newChildPath = "E:\VMs\newchild.vhdx" New-VHD -ParentPath $parentPath -Path $newChildPath -Differencing Advanced Script: Auto-Repair with Backup Fallback <# .SYNOPSIS Attempts to repair a VHDX file, falling back to a backup copy. .DESCRIPTION Uses Repair-VHD if possible. If that fails, mounts the VHDX read-only, runs chkdsk, and then replaces with a backup if corruption persists. #> param( [Parameter(Mandatory=$true)] [string]$VhdPath,
Import-Module Hyper-V -Force Copy-Item -Path $VhdPath -Destination $BackupPath -Force Write-Host "Original VHDX backed up to $BackupPath" Step 2: Try Repair-VHD try Write-Host "Attempting Repair-VHD..." $result = Repair-VHD -Path $VhdPath -Path $HealthyCopyPath -Passthru -ErrorAction Stop Write-Host "Repair-VHD succeeded. State: $($result.State)" exit 0
$fixedVHD = Repair-VHD -Path "E:\Corrupt\data.vhdx" -Path "F:\Backups\data_clean.vhdx" -Passthru $fixedVHD | Format-List *
[Parameter(Mandatory=$true)] [string]$HealthyCopyPath, repair vhdx powershell
Optimize-VHD -Path "C:\VHDX\suspect.vhdx" -Mode Full If a differencing VHDX is corrupt and its parent is healthy: $fixedVHD = Repair-VHD -Path "E:\Corrupt\data
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." If that fails, mounts the VHDX read-only, runs
[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
# Recreate the differencing disk from healthy parent $parentPath = "D:\BaseImages\parent.vhdx" $newChildPath = "E:\VMs\newchild.vhdx" New-VHD -ParentPath $parentPath -Path $newChildPath -Differencing Advanced Script: Auto-Repair with Backup Fallback <# .SYNOPSIS Attempts to repair a VHDX file, falling back to a backup copy. .DESCRIPTION Uses Repair-VHD if possible. If that fails, mounts the VHDX read-only, runs chkdsk, and then replaces with a backup if corruption persists. #> param( [Parameter(Mandatory=$true)] [string]$VhdPath,
Import-Module Hyper-V -Force Copy-Item -Path $VhdPath -Destination $BackupPath -Force Write-Host "Original VHDX backed up to $BackupPath" Step 2: Try Repair-VHD try Write-Host "Attempting Repair-VHD..." $result = Repair-VHD -Path $VhdPath -Path $HealthyCopyPath -Passthru -ErrorAction Stop Write-Host "Repair-VHD succeeded. State: $($result.State)" exit 0
Дисклеймер. Это рекламный сайт, все файлы, размещенные здесь, предназначены только для ознакомления. Все файлы, найденные на этом сайте, были собраны из различных источников в Интернете и считаются «общественными».
Zakachai1.ru - Скачайте рингтоны и мелодии на телефон ©
Администрация: admin@zakachai1.ru