fixes galore
This commit is contained in:
parent
cddc9fe04e
commit
966d8ccda1
@ -6,7 +6,7 @@
|
|||||||
# 2021
|
# 2021
|
||||||
#
|
#
|
||||||
|
|
||||||
$logFile="C:\ACS\disk_check.log"
|
$logFile="C:\ACS\disk_check.txt"
|
||||||
$computerName='localhost'
|
$computerName='localhost'
|
||||||
$rebootTime=Get-Date "1:00"
|
$rebootTime=Get-Date "1:00"
|
||||||
$requireReboot=$false
|
$requireReboot=$false
|
||||||
@ -15,18 +15,22 @@ $volumes=Get-Volumes -CimSession $cimSession
|
|||||||
Function Write-Log{
|
Function Write-Log{
|
||||||
Param ([string]$logstring)
|
Param ([string]$logstring)
|
||||||
|
|
||||||
|
if (-not(Test-Path -Path $logFile -PathType Leaf)) {
|
||||||
|
Add-Item -ItemType File -Path $logFile -Force
|
||||||
|
}
|
||||||
|
|
||||||
Add-Content $logFile -value $logstring
|
Add-Content $logFile -value $logstring
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($i in $volumes) {
|
foreach ($i in $volumes) {
|
||||||
$result=Repair-Volume -FileSystemLabel $v.FileSystemLabel -Scan
|
$result=Repair-Volume -FileSystemLabel $i.FileSystemLabel -Scan
|
||||||
|
|
||||||
if ($result.value -gt 0) {
|
if ($result.value -gt 0) {
|
||||||
Repair-Volume -FileSystemLabel $v.FileSystemLabel -Scan -OfflineScanAndFix
|
Repair-Volume -FileSystemLabel $i.FileSystemLabel -Scan -OfflineScanAndFix
|
||||||
$requireReboot = $true
|
$requireReboot = $true
|
||||||
} else {
|
} else {
|
||||||
Write-Output "$(v.FileSystemLabel): Drive is OK!"
|
Write-Output "$(i.FileSystemLabel): Drive is OK!"
|
||||||
Write-Log $now + ',' + $volume.FileSystemLabel + ',' + $result + ',' + $targetComputer
|
Write-Log $now + ',' + $i.FileSystemLabel + ',' + $result + ',' + $targetComputer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user