Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Windows Server

DISM RestoreHealth and SFC: repair a Windows server image

Repair corrupted Windows system files with DISM CheckHealth, ScanHealth and RestoreHealth, then SFC, with an ISO as the source when Windows Update fails.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of a cracked window pane being rebuilt tile by tile from a stack of translucent disc layers
On this pageWhat each command does

When Windows updates keep failing, a feature refuses to install, or System File Checker reports files it cannot fix, the damage is usually in the component store, the C:\Windows\WinSxS folder that holds the reference copy of every system file. Two built-in tools deal with it. DISM checks and repairs the component store itself. SFC then compares the files Windows actually uses against that store and replaces bad copies. Microsoft's advice is to run them in that order, DISM first, because SFC can only repair from a healthy store.

What each command does

Command What it does Where good files come from
DISM /CheckHealth Reports whether corruption was already recorded; no scan Nothing
DISM /ScanHealth Scans the component store and records what it finds Nothing, it only reports
DISM /RestoreHealth Scans and repairs the component store Windows Update, or a source you name
sfc /scannow Checks protected system files in use The component store

Before you start

Open Command Prompt or PowerShell with Run as administrator; both tools refuse to work otherwise. If a reboot is pending from earlier updates, restart first, since half-installed updates confuse the scans. Make sure C: has free space, because a repair downloads and stages files. And on a production server, take a snapshot so a bad day does not get worse; on CloudSat that is one click in the console (take a snapshot).

Step 1: check, then scan

DISM /Online /Cleanup-Image /CheckHealth
DISM /Online /Cleanup-Image /ScanHealth

/Online targets the running system. CheckHealth returns in seconds because it only reads what earlier operations recorded. ScanHealth reads the whole store and can take a long time on a busy disk. Each ends with one of three verdicts: no corruption detected, the store is repairable, or it is not repairable. A non-repairable store is rare and points toward an in-place repair install or a rebuild.

Step 2: repair with RestoreHealth

DISM /Online /Cleanup-Image /RestoreHealth

By default DISM downloads replacement files from Windows Update. The progress counter can sit on one percentage for many minutes; that is normal, so do not cancel it. Success ends with The restore operation completed successfully. If you prefer PowerShell, the same three operations exist as a cmdlet:

Repair-WindowsImage -Online -CheckHealth
Repair-WindowsImage -Online -ScanHealth
Repair-WindowsImage -Online -RestoreHealth

When Windows Update cannot be the source

The classic failure is error 0x800f081f, "The source files could not be found". It happens when Windows Update is blocked, broken itself, or replaced by an internal update server that does not carry repair content. The fix is to give DISM a local source.

Use a matching ISO

The source must be the same Windows version, edition and language as the server. Microsoft adds two rules: prefer the original release media, and keep the source at least as patched as the target, because a server with newer updates than the image can need files the image does not contain. Copy the ISO to the server, mount it and find the edition index:

Mount-DiskImage -ImagePath C:\iso\windows-server.iso
Get-Volume | Where-Object DriveType -eq 'CD-ROM'
DISM /Get-WimInfo /WimFile:D:\sources\install.wim

Windows Server ISOs list the Server Core and Desktop Experience variants of each edition separately, so pick the index that matches what you installed. Adding /Index:2 to the Get-WimInfo command prints that image's exact version and build; compare it with what winver shows on the server. Then point DISM at it and stop it from trying Windows Update with /LimitAccess:

DISM /Online /Cleanup-Image /RestoreHealth /Source:WIM:D:\sources\install.wim:2 /LimitAccess

Some media ship install.esd instead of install.wim; use the ESD: prefix with the same index syntax, for example /Source:ESD:D:\sources\install.esd:2.

Or let repairs bypass your update server

Servers that take updates from WSUS often fail repairs because WSUS does not serve repair files. The Group Policy setting Computer Configuration > Administrative Templates > System > Specify settings for optional component installation and component repair can name an alternate source path, or tell Windows to download repair content directly from Windows Update instead of WSUS. Run gpupdate /force after changing it.

Step 3: run System File Checker

sfc /scannow

SFC ends with one of four messages:

  • Windows Resource Protection did not find any integrity violations. Nothing to fix.
  • Windows Resource Protection found corrupt files and successfully repaired them. Done; the details are in the log.
  • Windows Resource Protection found corrupt files but was unable to fix some of them. Find the file in the log and replace it with a known-good copy, or repeat DISM with a better source.
  • Windows Resource Protection could not perform the requested operation. Try again in safe mode, and check that the PendingDeletes and PendingRenames folders exist under %WinDir%\WinSxS\Temp.

Read the logs

DISM writes to %windir%\Logs\DISM\dism.log, and both DISM and SFC write to %windir%\Logs\CBS\CBS.log. The CBS log is noisy, so extract the SFC lines into a separate file:

findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log > "%userprofile%\Desktop\sfcdetails.txt"

The output covers every SFC run on the machine, so read the timestamps to find the latest one.

When Windows will not boot

The same tools work offline from the Windows Recovery Environment or from the installation media's command prompt. In that environment the Windows partition may not be C:, so check the letters with diskpart and list volume first. Then repair the offline image and its files:

DISM /Image:C:\ /Cleanup-Image /RestoreHealth /Source:WIM:D:\sources\install.wim:2
sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows

If DISM complains about scratch space in the recovery environment, create a folder such as C:\Scratch and add /ScratchDir:C:\Scratch to the command. On a virtual server you need console access for all of this, because Remote Desktop is gone when Windows does not start. CloudSat provides a rescue or VNC console on request (recovery tools).

After the repair

Install pending updates and restart. Once the server is stable, you can reclaim the space taken by superseded components with DISM /Online /Cleanup-Image /StartComponentCleanup; more ways to recover space are in freeing and extending disk space on Windows. If updates still fail after a clean DISM and SFC run, the remaining options are an in-place repair install from matching media, where your edition supports it, or a fresh server with your data restored.

FAQ

Should I run SFC or DISM first?

DISM first. SFC repairs files from the component store, and DISM is what makes sure that store is healthy. Running SFC against a damaged store just reports files it cannot fix.

Does DISM need an internet connection?

Only when Windows Update is the repair source. With a mounted ISO and /LimitAccess, it works with no network at all.

Can I repair Windows Server with a Windows 11 ISO?

No. The source has to match the installed product, edition and language, and ideally its build. A Windows 11 image does not contain the server components, so DISM either fails to find files or refuses the source.

Is it safe to run on a production server?

Yes, as far as the tools go: they only replace system files with known-good copies. Run them in a maintenance window anyway, because the scans load the disk, a repair can require a restart, and a snapshot taken first costs little.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.