Updated the manuals

This commit is contained in:
Markus Fleschutz
2024-03-27 17:36:59 +01:00
parent c5b5cb1c6e
commit aed2b7d940
610 changed files with 1754 additions and 1120 deletions

View File

@@ -9,7 +9,7 @@ Parameters
PS> ./check-drives.ps1 [[-minLevel] <Int64>] [<CommonParameters>]
-minLevel <Int64>
Specifies the minimum warning level (10 GB by default)
Specifies the minimum warning level (10GB by default)
Required? false
Position? 1
@@ -26,8 +26,8 @@ Example
-------
```powershell
PS> ./check-drives.ps1
Drive C: uses 49%, 512GB free of 1TB
Drive D: uses 84%, 641GB free of 4TB
Drive C: has 512GB free (49% of 1TB used)
Drive D: has 641GB free (84% of 4TB used)
```
@@ -48,11 +48,11 @@ Script Content
.DESCRIPTION
This PowerShell script queries the free space of all drives and prints it.
.PARAMETER minLevel
Specifies the minimum warning level (10 GB by default)
Specifies the minimum warning level (10GB by default)
.EXAMPLE
PS> ./check-drives.ps1
✅ Drive C: uses 49%, 512GB free of 1TB
✅ Drive D: uses 84%, 641GB free of 4TB
✅ 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
@@ -61,24 +61,19 @@ Script Content
param([int64]$minLevel = 10) # 10 GB minimum
function Bytes2String { param([int64]$bytes)
if ($bytes -lt 1000) { return "$bytes bytes" }
$bytes /= 1000
if ($bytes -lt 1000) { return "$($bytes)KB" }
$bytes /= 1000
if ($bytes -lt 1000) { return "$($bytes)MB" }
$bytes /= 1000
if ($bytes -lt 1000) { return "$($bytes)GB" }
$bytes /= 1000
if ($bytes -lt 1000) { return "$($bytes)TB" }
$bytes /= 1000
return "$($bytes)PB"
function Bytes2String { param([int64]$number)
if ($number -lt 1KB) { return "$number bytes" }
if ($number -lt 1MB) { return '{0:N0}KB' -f ($number / 1KB) }
if ($number -lt 1GB) { return '{0:N0}MB' -f ($number / 1MB) }
if ($number -lt 1TB) { return '{0:N0}GB' -f ($number / 1GB) }
if ($number -lt 1PB) { return '{0:N0}TB' -f ($number / 1TB) }
return '{0:N0}GB' -f ($number / 1PB)
}
try {
Write-Progress "Querying drives..."
$drives = Get-PSDrive -PSProvider FileSystem
$minLevel *= 1000 * 1000 * 1000
$minLevel *= 1GB
Write-Progress -completed " "
foreach($drive in $drives) {
$details = (Get-PSDrive $drive.Name)
@@ -94,8 +89,8 @@ try {
} elseif ($free -lt $minLevel) {
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%, $(Bytes2String $free) free of $(Bytes2String $total)"
[int64]$percent = ($used * 100) / $total
Write-Host "✅ Drive $name has $(Bytes2String $free) free ($percent% of $(Bytes2String $total) used)"
}
}
exit 0 # success
@@ -105,4 +100,4 @@ try {
}
```
*(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 01/25/2024 13:58:36)*
*(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 03/27/2024 17:36:24)*