getting rid of cimsession
This commit is contained in:
parent
0f1f190258
commit
cddc9fe04e
@ -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!"
|
||||||
|
Loading…
Reference in New Issue
Block a user