getting rid of cimsession

This commit is contained in:
Wyatt J. Miller 2021-06-16 20:12:40 -04:00
parent 0f1f190258
commit cddc9fe04e

View File

@ -8,7 +8,6 @@
$logFile="C:\ACS\disk_check.log" $logFile="C:\ACS\disk_check.log"
$computerName='localhost' $computerName='localhost'
$cimSession=New-PSSession $computerName
$rebootTime=Get-Date "1:00" $rebootTime=Get-Date "1:00"
$requireReboot=$false $requireReboot=$false
$volumes=Get-Volumes -CimSession $cimSession $volumes=Get-Volumes -CimSession $cimSession
@ -20,10 +19,10 @@ Function Write-Log{
} }
foreach ($i in $volumes) { foreach ($i in $volumes) {
$result=Repair-Volume -CimSession $cimSession -FileSystemLabel $v.FileSystemLabel -Scan $result=Repair-Volume -FileSystemLabel $v.FileSystemLabel -Scan
if ($result.value -gt 0) { if ($result.value -gt 0) {
Repair-Volume -CimSession $cimSession -FileSystemLabel $v.FileSystemLabel -Scan -OfflineScanAndFix Repair-Volume -FileSystemLabel $v.FileSystemLabel -Scan -OfflineScanAndFix
$requireReboot = $true $requireReboot = $true
} else { } else {
Write-Output "$(v.FileSystemLabel): Drive is OK!" Write-Output "$(v.FileSystemLabel): Drive is OK!"