mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 00:13:36 +01:00
Updated check-drive-space.ps1, check-drives.ps1, and
check-swap-space.ps1
This commit is contained in:
parent
1fd0b93746
commit
a316ad6e27
@ -9,7 +9,7 @@
|
||||
Specifies the minimum level in bytes (10GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-drive-space.ps1 C
|
||||
✅ Drive C: uses 56% of 1TB · 442GB free
|
||||
✅ Drive C: has 442GB free (56% of 1TB used)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -49,7 +49,7 @@ try {
|
||||
Write-Host "⚠️ Drive $driveName with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||
} else {
|
||||
[int]$percent = ($used * 100) / $total
|
||||
Write-Host "✅ Drive $driveName uses $percent% of $(Bytes2String $total) · $(Bytes2String $free) free"
|
||||
Write-Host "✅ Drive $driveName has $(Bytes2String $free) free ($percent% of $(Bytes2String $total) used)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -7,8 +7,8 @@
|
||||
Specifies the minimum warning level (10GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-drives.ps1
|
||||
✅ Drive C: uses 49% of 1TB · 512GB free
|
||||
✅ Drive D: uses 84% of 4TB · 641GB free
|
||||
✅ Drive C: has 512GB free (49% of 1TB used)
|
||||
✅ Drive D: has 641GB free (84% of 4TB used)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -46,7 +46,7 @@ try {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||
} else {
|
||||
[int]$percent = ($used * 100) / $total
|
||||
Write-Host "✅ Drive $name uses $percent% of $(Bytes2String $total) · $(Bytes2String $free) free"
|
||||
Write-Host "✅ Drive $name has $(Bytes2String $free) free ($percent% of $(Bytes2String $total) used)"
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
|
@ -7,7 +7,7 @@
|
||||
Specifies the minimum level in GB (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-swap-space.ps1
|
||||
✅ Swap space uses 42% of 1GB · 748MB free
|
||||
✅ Swap space has 748MB free (42% of 1GB used)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -50,12 +50,12 @@ try {
|
||||
} elseif ($free -eq 0) {
|
||||
Write-Output "⚠️ Swap space of $(MB2String $total) is full"
|
||||
} elseif ($free -lt $minLevel) {
|
||||
Write-Output "⚠️ Swap space of $(MB2String $total) is nearly full · only $(MB2String $free) free"
|
||||
Write-Output "⚠️ Swap space has only $(MB2String $free) of $(MB2String $total) free"
|
||||
} elseif ($used -lt 5) {
|
||||
Write-Output "✅ Swap space unused · $(MB2String $free) free"
|
||||
Write-Output "✅ Swap space has the full $(MB2String $free) free"
|
||||
} else {
|
||||
[int]$Percent = ($used * 100) / $total
|
||||
Write-Output "✅ Swap space uses $Percent% of $(MB2String $total) · $(MB2String $free) free"
|
||||
Write-Output "✅ Swap space has $(MB2String $free) free ($Percent% of $(MB2String $total) used)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user