Skip to main content

Run DISM and SFC for System Repair

This PowerShell script performs a two-step process to repair system integrity issues on Windows. It first runs the DISM tool to restore the system image and then executes SFC to scan and repair system files, only if DISM completes successfully.

⚙️ Features

  • Automates the standard DISM + SFC repair sequence

  • Color-coded console messages for success or failure

  • Check DISM completion before running SFC to avoid redundant operations

💻 Script
# Run DISM to repair the system image
Write-Host "Running DISM repair..." -ForegroundColor Green
dism /online /cleanup-image /restorehealth

# Check if DISM was successful before running SFC
if ($?) {
    Write-Host "DISM completed successfully. Running SFC..." -ForegroundColor Green
    # Run SFC to scan and repair system files
    sfc /scannow
} else {
    Write-Host "DISM failed. Please check the DISM logs for errors." -ForegroundColor Red
}

📝 Notes

  • Requires Administrator privileges

  • Best used when:

    • Windows features aren't working correctly

    • Updates fail repeatedly

    • System file corruption is suspected

  • Log files:

    • DISM: %windir%\Logs\DISM\dism.log

    • SFC: %windir%\Logs\CBS\CBS.log

Useful for repairing Windows Update problems, broken system features, and post-malware cleanup.