From 10bd04c73d75842eab0a73f86c78032ec1d9efad Mon Sep 17 00:00:00 2001 From: David Yoder Date: Wed, 23 Nov 2022 15:52:30 -0500 Subject: [PATCH] added function Test-RegistryProperty --- Fix-WindowsHealth.ps1 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Fix-WindowsHealth.ps1 b/Fix-WindowsHealth.ps1 index 17a527d..e0a7a37 100644 --- a/Fix-WindowsHealth.ps1 +++ b/Fix-WindowsHealth.ps1 @@ -1,8 +1,14 @@ +$ScheduleCheckDisk = $false + # 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 +$SFCOutputWithSpaces = " W i n d o w s R e s o u r c e P r o t e c t i o n d i d n o t f i n d a n y i n t e g r i t y v i o l a t i o n s ." +$SFCOutputWithoutSpaces = "Windows Resource Protection did not find any integrity violations." +If ( !($SFCOutput -match $SFCOutputWithSpaces) -or !($SFCOutput -match $SFCOutputWithoutSpaces) ) { $ScheduleCheckDisk = $true } + # Run enhanced DISM for Windows 8 and higher endpoints If ( IsWindowsVersion -ge "6.2" ) { @@ -26,4 +32,10 @@ If ( IsWindowsVersion -ge "6.2" ) } LogMsg "Completed Windows Component Store log data collection" } -Else { LogMsg "Online image cleanup and restoration is only supported on Windows 8 and higher" } \ No newline at end of file +Else { LogMsg "Online image cleanup and restoration is only supported on Windows 8 and higher" } + +# Schedule Check Disk if needed +If ( $ScheduleCheckDisk ) { + LogMsg "Check Disk scheduled to repair disk at next boot" + & echo y | chkdsk /F /R /X +} \ No newline at end of file