big update
This commit is contained in:
+14
-26
@@ -1,39 +1,27 @@
|
|||||||
## Run enhanced DISM for Windows 8 and higher endpoints
|
# 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" )
|
If ( IsWindowsVersion -ge "6.2" )
|
||||||
{
|
{
|
||||||
LogMsg "Fix-WindowsHealth.ps1"
|
|
||||||
|
|
||||||
$BeginDISMRun = $(Get-Date).AddSeconds(-1)
|
$BeginDISMRun = $(Get-Date).AddSeconds(-1)
|
||||||
|
|
||||||
## Scan the Windows Component Store for problems
|
LogMsg "Beginning repair of Windows Component Store"
|
||||||
LogMsg "Beginning Windows Component Store scan"
|
StartProcess "dism.exe" -ArgumentList "/online /cleanup-image /restorehealth" -Wait
|
||||||
Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /scanhealth" -Wait
|
|
||||||
LogMsg "Completed Windows Component Store scan"
|
|
||||||
|
|
||||||
## Check to see if the previous command recorded any problems that need repairing
|
LogMsg "Beginning cleanup of superceded components in Windows Component Store"
|
||||||
LogMsg "Beginning Windows Component Store health check"
|
StartProcess "dism.exe" -ArgumentList "/online /cleanup-image /startcomponentcleanup"
|
||||||
$CheckHealthOutput = $(dism /online /cleanup-image /checkhealth) | Out-String
|
|
||||||
If ( $CheckHealthOutput -match "repairable" )
|
|
||||||
{
|
|
||||||
LogMsg "Completed Windows Component Store health check: Problems found"
|
|
||||||
|
|
||||||
## Repair problems with the Windows Component Store
|
|
||||||
LogMsg "Beginning Windows Component Store restoration"
|
|
||||||
Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /restorehealth" -Wait
|
|
||||||
LogMsg "Completed Windows Component Store restoration"
|
|
||||||
}
|
|
||||||
Else { LogMsg "Completed Windows Component Store health check: No problems found" }
|
|
||||||
|
|
||||||
$EndDISMRun = $(Get-Date).AddSeconds(1)
|
$EndDISMRun = $(Get-Date).AddSeconds(1)
|
||||||
|
|
||||||
## Parse DISM log file for recent activity
|
# Adding results of DISM log file to this log file
|
||||||
$DISMLogFile = "${MSPLogs}\Fix-WindowsHealth_DISM.log"
|
|
||||||
If ( Test-Path $DISMLogFile ) { Remove-Item $DISMLogFile -Force }
|
|
||||||
New-Item -Path $DISMLogFile -ItemType File
|
|
||||||
LogMsg "Beginning Windows Component Store log data collection"
|
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})' |
|
Get-Content -Path "${Env:WinDir}\Logs\DISM\dism.log" | Select-String -Pattern '^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' |
|
||||||
% { If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) {
|
ForEach-Object {
|
||||||
Add-Content -Path $DISMLogFile -Value $_.Line
|
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"
|
LogMsg "Completed Windows Component Store log data collection"
|
||||||
|
|||||||
Reference in New Issue
Block a user