-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisks.Tests.ps1
37 lines (30 loc) · 1.55 KB
/
Disks.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$FreeSystemDriveMBytesThreshold = 5000
$FreeSystemDrivePctThreshold = .05
$FreeNonSystemDriveMBytesThreshold = 1000
$FreeNonSystemDrivePctThreshold = .05
describe 'Logical Disks' {
$vols = Get-Volume | Where-Object { $_.DriveType -eq 'Fixed' -and -not [string]::IsNullOrEmpty($_.DriveLetter)}
context 'Availablity' {
$vols | ForEach-Object {
it "Volume [$($_.DriveLetter)] is healthy" {
$_.HealthStatus | Should be 'Healthy'
}
}
}
context 'Capacity' {
$systemDriveLetter = $env:SystemDrive.Substring(0, 1)
$sysVol = $vols | Where-Object DriveLetter -eq $systemDriveLetter
$nonSysVols = $vols | Where-Object DriveLetter -NE $systemDriveLetter
it "System drive [$systemDriveLetter] has $FreeSystemDriveMBytesThreshold MB and $('{0:p0}' -f $FreeSystemDrivePctThreshold) free" {
($sysVol.SizeRemaining / 1MB) -ge $FreeSystemDriveMBytesThreshold | Should be $true
($sysVol.SizeRemaining / $sysVol.Size) -ge $FreeSystemDriveThresholdPct | Should be $true
}
foreach ($volume in $nonSysVols) {
$driveLetter = $volume.DriveLetter
it "Non-System drive [$driveLetter] has greater than $FreeNonSystemDriveMBytesThreshold MB and $('{0:p0}' -f $FreeNonSystemDrivePctThreshold) free" {
($volume.SizeRemaining / 1MB) -ge $FreeNonSystemDriveThreshold | Should be $true
($volume.SizeRemaining / $volume.Size) -ge $FreeNonSystemDriveThresholdPct | Should be $true
}
}
}
}