I seem to always have to go hunting for the syntax to run DISM /restorehealth, so here are a few quick examples.
The basic command for online cleanup:
dism /Online /Cleanup-Image /RestoreHealth
If it complains about not finding sources, you can mount the installation ISO (right click, Mount), then use it as a drive. Let’s assume it’s a .wim file on drive F.
First we need to determine which index of the WIM file contains the OS you are repairing:
dism /Get-WimInfo /WimFile:F:\sources\install.wim
In this case, we want index 2, Server 2016 with a GUI (“Desktop Experience”). Specify that index after the last colon in the /Source parameter:
dism /Online /Cleanup-Image /RestoreHealth /Source:wim:F:\sources\install.wim:2
If using a Windows 10 USB with an ESD file, use this command:
dism /Get-WimInfo /WimFile:F:\x64\sources\install.esd
and then, if the desired version of Windows 10 is at index 6 (notice /Source
instead of /WimFile
):
dism /Online /Cleanup-Image /RestoreHealth /Source:wim:F:\x64\sources\install.esd:6