mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Update check-drives.ps1
This commit is contained in:
parent
6da9a90a3e
commit
46aff13090
@ -1,21 +1,16 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks all drives for free space left
|
Checks the free space of all drives
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script checks all drives for free space left (20 GB by default).
|
This PowerShell script checks all drives for free space left (20 GB by default).
|
||||||
.PARAMETER MinLevel
|
|
||||||
Specifies the minimum level in Gigabyte
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-drives
|
PS> ./check-drives
|
||||||
✔️ Drive C has 172GB left (233GB total)
|
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz / License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([int]$MinLevel = 20) # minimum level in GB
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Drives = Get-PSDrive -PSProvider FileSystem
|
$Drives = Get-PSDrive -PSProvider FileSystem
|
||||||
foreach($Drive in $Drives) {
|
foreach($Drive in $Drives) {
|
||||||
@ -31,10 +26,10 @@ try {
|
|||||||
} else {
|
} else {
|
||||||
$Reply = "Drive $($Drive.Name) has $($Free) GB left, $($Total) GB total."
|
$Reply = "Drive $($Drive.Name) has $($Free) GB left, $($Total) GB total."
|
||||||
}
|
}
|
||||||
& "$PSScriptRoot/give-reply.ps1" "$Reply"
|
"* $Reply"
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user