Repair Windows Server 2016 Error 0x800f081f

Run this function in PowerShell as Administrator:

function resetWindowsUpdate{
    # Source: https://docs.microsoft.com/en-us/windows/deployment/update/windows-update-resources
    write-host 'Resetting Windows updates...'
    $originalLocation=get-location
    stop-Service wuauserv -force
    stop-Service cryptSvc -force # This may not work due to certain antivirus dependencies
    stop-Service bits -force
    stop-Service msiserver -force
    Rename-Item "$env:systemroot\SoftwareDistribution" SoftwareDistribution.bak
    if((get-service cryptSvc -ea silentlycontinue).status -eq 'Stopped'){
        Rename-Item "$env:systemroot\System32\catroot2" Catroot2.bak
    }else{
        write-warning "$env:systemroot\System32\catroot2 was not renamed."
    }
    set-location "$env:windir\system32"
    regsvr32 c:\windows\system32\vbscript.dll /s
    regsvr32 c:\windows\system32\mshtml.dll /s    
    regsvr32 c:\windows\system32\msjava.dll /s
    regsvr32 c:\windows\system32\jscript.dll /s    
    regsvr32 c:\windows\system32\msxml.dll /s    
    regsvr32 c:\windows\system32\actxprxy.dll /s    
    regsvr32 c:\windows\system32\shdocvw.dll /s    
    regsvr32 wuapi.dll /s    
    regsvr32 wuaueng1.dll /s    
    regsvr32 wuaueng.dll /s    
    regsvr32 wucltui.dll /s    
    regsvr32 wups2.dll /s    
    regsvr32 wups.dll /s    
    regsvr32 wuweb.dll /s    
    regsvr32 Softpub.dll /s    
    regsvr32 Mssip32.dll /s    
    regsvr32 Initpki.dll /s    
    regsvr32 softpub.dll /s    
    regsvr32 wintrust.dll /s    
    regsvr32 initpki.dll /s    
    regsvr32 dssenh.dll /s    
    regsvr32 rsaenh.dll /s    
    regsvr32 gpkcsp.dll /s    
    regsvr32 sccbase.dll /s    
    regsvr32 slbcsp.dll /s    
    regsvr32 cryptdlg.dll /s    
    regsvr32 Urlmon.dll /s    
    regsvr32 Shdocvw.dll /s    
    regsvr32 Msjava.dll /s    
    regsvr32 Actxprxy.dll /s    
    regsvr32 Oleaut32.dll /s    
    regsvr32 Mshtml.dll /s    
    regsvr32 msxml.dll /s    
    regsvr32 msxml2.dll /s    
    regsvr32 msxml3.dll /s
    regsvr32 Browseui.dll /s    
    regsvr32 shell32.dll /s    
    regsvr32 wuapi.dll /s    
    regsvr32 wuaueng.dll /s    
    regsvr32 wuaueng1.dll /s    
    regsvr32 wucltui.dll /s    
    regsvr32 wups.dll /s    
    regsvr32 wuweb.dll /s    
    regsvr32 jscript.dll /s
    regsvr32 atl.dll /s    
    regsvr32 Mssip32.dll /s
    netsh winsock reset
    start-service wuauserv
    start-service cryptSvc
    start-service bits    
    start-service msiserver
    bitsadmin.exe /reset /allusers
    DISM.exe /Online /Cleanup-image /Restorehealth    
    set-location $originalLocation
    write-host 'Done.'
}

resetWindowsUpdate
Symptom:
PS C:\Windows\system32> Install-WindowsFeature DHCP -IncludeManagementTools
Install-WindowsFeature : The request to add or remove features on the specified server failed.
Installation of one or more roles, role services, or features failed.
The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more
information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f081f
At line:1 char:1
+ Install-WindowsFeature DHCP -IncludeManagementTools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:PSObject) [Install-WindowsFeature],
Exception
+ FullyQualifiedErrorId : DISMAPI_Error__Failed_To_Enable_Updates,Microsoft.Windows.ServerManager.Commands.AddWind
owsFeatureCommand

Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
False No Failed {}
Resolution:
# Clean up Windows Component Store, aka WinSXS (C:\Windows\winsxs)
DISM /Online /Cleanup-Image /StartComponentCleanup # fix WinSXS
# SFC /SCANNOW # fix corrupted system files
DISM /Online /Cleanup-Image /AnalyzeComponentStore # check WinSXS
# SFC /SCANNOW
# Restart-Computer # reboot to render changes effective
# Perform Windows Repair using Microsoft Windows Update sources (may not work):
# Run Restore Health after reboot
DISM /Online /Cleanup-Image /RestoreHealth

# PowerShell native command to restore health
Repair-WindowsImage -Online -RestoreHealth
# Perform Windows Repair using Windows ISO as the source (works better):

# Specify ISO Path to automatically generate the rest of the other variables
# Obtain ISO from Microsoft at https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2016/
# https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO
$isoPath="\\it-fs2\it$\Software\ISO's\SW_DVD9_Win_Server_STD_CORE_2016_64Bit_English_-4_DC_STD_MLF_X21-70526.iso"

# Autogen variables:
$isoMount=Mount-DiskImage $isoPath -PassThru
$driveLetter=($isoMount | get-volume).DriveLetter
$wimPath="$driveLetter`:\sources\install.wim:1"
$logPath="C:\Temp\dism-repair-windows.log"

# Restore Windows Health using provided ISO:
dism /online /cleanup-image /restorehealth /source:WIM:$wimPath /limitaccess # non-native PowerShell command
# Repair-WindowsImage -Online -RestoreHealth -Source $wimPath -LimitAccess -LogPath $logPath


# Dismount ISO when done
Dismount-DiskImage -ImagePath $isoPath
Sample Output:
# Failure scenario

PS C:\Windows\system32> dism /online /cleanup-image /restorehealth

Deployment Image Servicing and Management tool
Version: 10.0.14393.3085

Image Version: 10.0.14393.3085

[==========================100.0%==========================]
Error: 0x800f081f

The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more informat
ion on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.

The DISM log file can be found at C:\Windows\Logs\DISM\dism.log
# Success scenario

PS C:\Windows\system32> DISM /Online /Cleanup-Image /StartComponentCleanup

Deployment Image Servicing and Management tool
Version: 10.0.14393.3085

Image Version: 10.0.14393.3085

[===== 10.0% ]

PS C:\Windows\system32> dism /online /cleanup-image /restorehealth

Deployment Image Servicing and Management tool
Version: 10.0.14393.3085

Image Version: 10.0.14393.3085

[==========================100.0%==========================]Done...

2 thoughts on “Repair Windows Server 2016 Error 0x800f081f”

  1. Hello…I found this article on Internet as my server 2016 crashed due to a power failure and then I believe when came back up was trying to do a Windows update. I got the same :Error: 0x800f081f” when trying to repair my windows 2016 osand am running the success scenario for doing a “startcomponentcleanup”

    However, i started that and it has been running for over 3 hours now and is at 10% still. Nothing appears like its frozen.

    Ideas?

    Thanks,

    Rob

    1. DISM certainly isn’t a perfect tool that would display progress and errors properly, although such info can be assumed via logs. In your case, I have several suggestions:
      a. Run DISM with ISO, instead of /online
      b. Wait up to 6 hours before determining that DISM has stuck
      c. Reboot the computer to retry the process
      d. Use a third party tool in lieu of dism
      e. Consider re-installing the OS

Leave a Reply

Your email address will not be published. Required fields are marked *