-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_spaces_phydisk.ps1
36 lines (34 loc) · 1.87 KB
/
check_spaces_phydisk.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
# 30.01.2019 # CL
# Check Storage Spaces Direct Disk
#
# Dieser Check prüft den Status aller Physical Disks
# und liefert die Summe der gesamten Festplatten
#
# Version 0.2
#
# Changelog: 24.02.2020 -Remove Whitespaces from SerialNumber (by Andreas, afaassl)
#
# PhysicalDisk
$pdisks = Get-PhysicalDisk | Where { $_.FriendlyName -ne "HP LOGICAL VOLUME" } | Select FriendlyName, SerialNumber, OperationalStatus, HealthStatus, Usage, Size, AllocatedSize, VirtualDiskFootprint
foreach ($pdisk in $pdisks) {
if ($pdisk.OperationalStatus -eq "OK" -and $pdisk.HealthStatus -eq "Healthy") {
# All good
$status = "0"
#Remove Whitespaces
$serial=$pdisk.SerialNumber.replace(' ','') #afassl
$diskname = $pdisk.Friendlyname -replace '\s',''
$diskname = $pdisk.Friendlyname -replace '/',''
$statusText = "OK - " + $diskname + " is in good state. OperationalStatus:" + $pdisk.OperationalStatus + " | HealthStatus:" + $pdisk.HealthStatus + " | Usage: " + $pdisk.Usage + " | Size:" + $pdisk.Size + " | SN:" + $serial
} else {
$status = "1"
$statusText = "Warning - " + $diskname + " is in unusual state. OperationalStatus:" + $pdisk.OperationalStatus + " | HealthStatus:" + $pdisk.HealthStatus + " | Usage: " + $pdisk.Usage + " | Size:" + $pdisk.Size + " | SN:" + $serial
}
$perfdataVirtualDisk = "size=" + $pdisk.Size + "|allocatedsize=" + $pdisk.AllocatedSize + "|virtualdiskfootprint=" + $pdisk.VirtualDiskFootprint
$stringToPost = $status + " S2D_PhysicalDisk_" + $serial + " " + $perfdataVirtualDisk + " " + $statusText
Write-Host $stringToPost
}
# Count of Physical Disks
$status = "0"
$stringToPost = $status + " S2D_SUM_PhysicalDisk count=" + $pdisks.Count + " Insgesamt " + $pdisks.Count + " Festplatten im System vorhanden."
Write-Host $stringToPost