From 10a445e0ff909c90d27d4a4f202c0ad0d4d4d7a4 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Fri, 16 Jul 2021 09:49:58 -0400 Subject: [PATCH] added reboot logic --- disk_check.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/disk_check.ps1 b/disk_check.ps1 index b556413..f2faeef 100644 --- a/disk_check.ps1 +++ b/disk_check.ps1 @@ -72,4 +72,23 @@ foreach ($i in $volumes) { if ($requireReboot -eq $true) { # TODO: Reboot logic goes here Write-Output "Reboot required!" + + do + { + Write-Output 'Sleeping while waiting for time window' + Write-Output 'Current Time:' + $now.TimeOfDay + $now = Get-Date + Start-Sleep -s 1200 #20 Minutes (1200 Seconds) + } + while ($now.TimeOfDay -gt $earliestRebootTime.TimeOfDay -and $now.TimeOfDay -lt $latestRebootTime.TimeOfDay) + + + #Reboot PC with Faulty Disk for Offline Repair + Restart-Computer -ComputerName $target -Force -Delay -Wait + + #Wait for Reboot and Scan PC with Faulty Disk + $result = Repair-Volume CimSession $cimSession -FileSystemLabel $volume.FileSystemLabel -Scan + + #Report Un-Repairable Disks + Write-Log $now +','+ $result + ',' + $targetComputer, +',' + 'Unable to repair' }