Skip to content

System Corruption Scan

functions/public/Invoke-WPFSystemRepair.ps1
 1function Invoke-WPFSystemRepair {
 2    <#
 3    .SYNOPSIS
 4        Checks for system corruption using SFC, and DISM
 5        Checks for disk failure using Chkdsk
 6
 7    .DESCRIPTION
 8        1. Chkdsk - Checks for disk errors, which can cause system file corruption and notifies of early disk failure
 9        2. SFC - scans protected system files for corruption and fixes them
10        3. DISM - Repair a corrupted Windows operating system image
11    #>
12
13    Start-Process cmd.exe -ArgumentList "/c chkdsk /scan /perf" -NoNewWindow -Wait
14    Start-Process cmd.exe -ArgumentList "/c sfc /scannow" -NoNewWindow -Wait
15    Start-Process cmd.exe -ArgumentList "/c dism /online /cleanup-image /restorehealth" -NoNewWindow -Wait
16
17    Write-Host "==> Finished System Repair"
18    Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
19}