Here is my IsWindowsHealthy.ps1 file. It tests some of the basic areas that might impact Windows Update. Save it and run it from an admin Powershell prompt. Let's see if it produces any errors.
Update: .ps1 works better than a .bat file.
#---------------------------------------------------------------------------#
# IsWindowsHealthy.ps1 - Run common troubleshooting tools.
# Author - MotoX80 on Microsoft Learn forum.
# Last update - 2025-01-09
# https://learn.microsoft.com/en-us/answers/questions/118183/how-to-fix-error-0x80070543-in-windows-10
# Any feedback is welcome.
#---------------------------------------------------------------------------#
cls
$color = "Yellow" # Your favorite color
while ($true) {
Write-Host -ForegroundColor $color "------------------------------------------"
Write-Host -ForegroundColor $color " Run check disk "
Write-Host -ForegroundColor $color "------------------------------------------"
chkdsk.exe c:
Write-Host ""
Write-Host -ForegroundColor $color "Chkdsk RC=$LASTEXITCODE"
if ($LASTEXITCODE -ne 0) {break}
Write-Host ""
Write-Host -ForegroundColor $color "------------------------------------------"
Write-Host -ForegroundColor $color " Dism CheckHealth "
Write-Host -ForegroundColor $color "------------------------------------------"
Dism.exe /Online /Cleanup-Image /CheckHealth
Write-Host ""
Write-Host -ForegroundColor $color "CheckHealth RC=$LASTEXITCODE"
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host -ForegroundColor $color " Try running 'Dism.exe /Online /Cleanup-Image /RestoreHealth'"
Write-Host -ForegroundColor $color " See if that fixes the dism problem."
Write-Host ""
break
}
Write-Host ""
Write-Host -ForegroundColor $color "------------------------------------------"
Write-Host -ForegroundColor $color " Dism ScanHealth"
Write-Host -ForegroundColor $color "------------------------------------------"
Dism.exe /Online /Cleanup-Image /ScanHealth
Write-Host ""
Write-Host -ForegroundColor $color "ScanHealth RC=$LASTEXITCODE"
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host -ForegroundColor $color " Try running 'Dism.exe /Online /Cleanup-Image /RestoreHealth'"
Write-Host -ForegroundColor $color " See if that fixes the dism problem."
Write-Host ""
break
}
Write-Host ""
Write-Host -ForegroundColor $color "------------------------------------------"
Write-Host -ForegroundColor $color " Dism AnalyzeComponentstore"
Write-Host -ForegroundColor $color "------------------------------------------"
Dism.exe /online /cleanup-image /AnalyzeComponentstore
Write-Host ""
Write-Host -ForegroundColor $color "AnalyzeComponentstore RC=$LASTEXITCODE"
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host -ForegroundColor $color " Try running 'Dism.exe /Online /Cleanup-Image /RestoreHealth'"
Write-Host -ForegroundColor $color " See if that fixes the dism problem."
Write-Host ""
break
}
Write-Host ""
Write-Host ""
Write-Host -ForegroundColor $color " If you see 'Component Store Cleanup Recommended : Yes'"
Write-Host -ForegroundColor $color " Run 'Dism.exe /online /Cleanup-Image /StartComponentCleanup'"
Write-Host ""
Write-Host ""
Write-Host -ForegroundColor $color "------------------------------------------"
Write-Host -ForegroundColor $color " System File Checker "
Write-Host -ForegroundColor $color "------------------------------------------"
sfc.exe /scannow
Write-Host ""
Write-Host -ForegroundColor $color "SFC RC=$LASTEXITCODE"
if ($LASTEXITCODE -ne 0) {break}
Write-Host ""
Write-Host -ForegroundColor $color "------------------------------------------"
Write-Host -ForegroundColor $color " Check the WMI repository "
Write-Host -ForegroundColor $color "------------------------------------------"
winmgmt.exe /verifyrepository
Write-Host ""
Write-Host -ForegroundColor $color "Winmgmt RC=$LASTEXITCODE"
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host -ForegroundColor $color " Try running 'Winmgmt.exe /salvagerepository'"
Write-Host -ForegroundColor $color " See if that fixes WMI."
Write-Host ""
break
}
Write-Host ""
Write-Host -ForegroundColor $color "--------------------------------------------------"
Write-Host -ForegroundColor $color " Folders in your system path. "
Write-Host -ForegroundColor $color " Remove duplicate entries and to be safe,"
Write-Host -ForegroundColor $color " put the %systemroot% entries first in the list."
Write-Host -ForegroundColor $color "--------------------------------------------------"
$env:Path.split(";")
Write-Host ""
Write-Host -ForegroundColor $color "---------------------------------------------"
Write-Host -ForegroundColor $color " Run the WindowsUpdate Troubleshooting Pack."
Write-Host ""
Write-Host -ForegroundColor $color " If updates are pending, select 'x' to exit."
Write-Host -ForegroundColor $color " Then install the updates when appropriate."
Write-Host -ForegroundColor $color "---------------------------------------------"
Get-TroubleshootingPack -path C:\Windows\diagnostics\system\WindowsUpdate | Invoke-TroubleshootingPack
Write-Host ""
Write-Host -ForegroundColor $color "---------------------------------------------"
Write-Host -ForegroundColor $color " Report on recent updates."
Write-Host -ForegroundColor $color "---------------------------------------------"
Get-CimInstance Win32_QuickFixEngineering | Sort-Object -Property InstalledOn -Descending | Format-Table -Property HotFixID, InstalledOn
Get-WUHistory -Last 10 | Format-Table -Property Date, Title
break
}
Write-Host -ForegroundColor $color "Complete"