Scan for Component Store Corruption (DISM)
This PowerShell script uses DISM /ScanHealth to check for corruption in the Windows Component Store. It captures the output and searches the logs for any corruption-related entries, optionally saving details to a text file for review.
🔍 Features
-
Runs
DISM /ScanHealthto check system health -
Logs output to a temporary file
-
Searches for corruption-related entries
-
Saves details about corrupted files (if found) to a text file
-
Useful for early detection of system integrity issues
💻 Script
# Run DISM to check for component store corruption
$logFile = "$env:TEMP\DISM.log"
$corruptFileList = "$env:TEMP\CorruptFiles.txt"
# Run the DISM command and capture the output
$DISMOutput = dism /Online /Cleanup-Image /ScanHealth 2>&1 | Tee-Object -FilePath $logFile
# Look for corruption indicators in the DISM log
$corruptEntries = $DISMOutput | Select-String "corrupt"
# Extract corrupted file paths (if any)
if ($corruptEntries) {
Write-Output "Corrupt files detected. Extracting details..."
# Read DISM logs to locate potential corrupt files
$dismLogPath = "C:\Windows\Logs\DISM\dism.log"
$foundFiles = Select-String -Path $dismLogPath -Pattern "(.+corrupt:.+)" -AllMatches | ForEach-Object { $_.Matches.Groups[1].Value }
if ($foundFiles) {
$foundFiles | Out-File -FilePath $corruptFileList
Write-Output "Corrupt files list saved to: $corruptFileList"
Get-Content $corruptFileList
} else {
Write-Output "Corruption detected, but no specific files were listed in the logs."
}
} else {
Write-Output "No corruption found."
}
📝 Notes
-
Admin rights are required to run this script.
-
Output files:
-
DISM Output:
$env:TEMP\DISM.log -
Corrupt File List:
$env:TEMP\CorruptFiles.txt
-
-
Log parsing may not identify every type of corruption. Always review
C:\Windows\Logs\DISM\dism.logmanually for critical diagnostics.
Use this script proactively to detect and investigate potential system health problems before they escalate.