mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-02 10:59:14 +01:00
Added check-drive-space.ps1
This commit is contained in:
parent
ac2f03adfe
commit
a6e05aa167
@ -1,5 +1,6 @@
|
||||
Script,Description
|
||||
add-firewall-rules.ps1, adds firewall rules to the given executables (requires admin rights)
|
||||
check-drive-space.ps1, checks the given drive for free space left
|
||||
check-ipv4-address.ps1, checks the given IPv4 address for validity
|
||||
check-ipv6-address.ps1, checks the given IPv6 address for validity
|
||||
check-mac-address.ps1, checks the given MAC address for validity
|
||||
|
|
@ -30,6 +30,7 @@ Scripts for Audio & Voice 🔊
|
||||
Scripts for Computer Management ⚙️
|
||||
---------------------------------
|
||||
* [add-firewall-rules.ps1](Scripts/add-firewall-rules.ps1) - adds firewall rules for the given executables (requires admin rights)
|
||||
* [check-drive-space.ps1](Scripts/check-drive-space.ps1) - checks the given drive for free space left
|
||||
* [enable-crash-dumps.ps1](Scripts/enable-crash-dumps.ps1) - enables the writing of crash dumps
|
||||
* [hibernate.ps1](Scripts/hibernate.ps1) - enables hibernate mode for the local computer (requires admin rights)
|
||||
* [list-network-shares.ps1](Scripts/list-network-shares.ps1) - lists the network shares of the local computer
|
||||
|
29
Scripts/check-drive-space.ps1
Executable file
29
Scripts/check-drive-space.ps1
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./check-drive-space.ps1 [<drive>] [<warning-level>]
|
||||
.DESCRIPTION checks the given drive for free space left
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
param($Drive = "", $WarningLevel = 50) #limit in gb
|
||||
|
||||
if ($Drive -eq "" ) {
|
||||
$Drive = read-host "Enter drive to check"
|
||||
}
|
||||
|
||||
try {
|
||||
$FreeSpace = (get-psdrive $Drive).free
|
||||
[int]$FreeSpace = (($FreeSpace / 1024) / 1024) / 1024
|
||||
|
||||
if ($FreeSpace -lt $WarningLevel) {
|
||||
write-warning "Drive $Drive has only $FreeSpace GB free space left! (warning level is < $WarningLevel GB)"
|
||||
exit 1
|
||||
} else {
|
||||
write-host -foregroundColor green "OK - drive $Drive has $FreeSpace GB free space left (warning level is < $WarningLevel GB)"
|
||||
exit 0
|
||||
}
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
write-host -foregroundColor green "Welcome to PowerShell $($PSVersionTable.PSVersion)"
|
||||
|
||||
#function prompt {$null} # PS>
|
||||
|
||||
#function prompt { "$ " } # $
|
||||
|
Loading…
Reference in New Issue
Block a user