29 lines
1.3 KiB
PowerShell
29 lines
1.3 KiB
PowerShell
# Run the System File Checker to scan for and repair any problems with protected system files
|
|
LogMsg "Running System File Checker"
|
|
$SFCOutput = $(sfc /scannow) | Out-String
|
|
LogMsg $SFCOutput
|
|
|
|
# Run enhanced DISM for Windows 8 and higher endpoints
|
|
If ( IsWindowsVersion -ge "6.2" )
|
|
{
|
|
$BeginDISMRun = $(Get-Date).AddSeconds(-1)
|
|
|
|
LogMsg "Beginning repair of Windows Component Store"
|
|
Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /restorehealth" -Wait
|
|
|
|
LogMsg "Beginning cleanup of superceded components in Windows Component Store"
|
|
Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /startcomponentcleanup" -Wait
|
|
|
|
$EndDISMRun = $(Get-Date).AddSeconds(1)
|
|
|
|
# Adding results of DISM log file to this log file
|
|
LogMsg "Beginning Windows Component Store log data collection"
|
|
Get-Content -Path "${Env:WinDir}\Logs\DISM\dism.log" | Select-String -Pattern '^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' |
|
|
ForEach-Object {
|
|
If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) {
|
|
LogMsg $_.Line
|
|
}
|
|
}
|
|
LogMsg "Completed Windows Component Store log data collection"
|
|
}
|
|
Else { LogMsg "Online image cleanup and restoration is only supported on Windows 8 and higher" } |