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