mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 00:54:04 +01:00
Update check-bios.ps1 and check-drives.ps1
This commit is contained in:
parent
91c06f41b2
commit
ebe50ff58e
@ -5,7 +5,7 @@
|
||||
This PowerShell script queries the BIOS status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-bios
|
||||
✅ F6 BIOS by American Megatrends Inc. (S/N NXA82EV0EBB0760, version ALASKA - 1072009)
|
||||
✅ BIOS F6 by American Megatrends Inc. (S/N NXA82EV0EBB0760, version ALASKA - 1072009)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,24 +13,26 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Querying BIOS details..."
|
||||
if ($IsLinux) {
|
||||
Write-Progress "⏳ Querying BIOS..."
|
||||
$Model = (sudo dmidecode -s system-product-name)
|
||||
if ("$Model" -ne "") {
|
||||
$Manufacturer = (sudo dmidecode -s system-manufacturer)
|
||||
$Version = (sudo dmidecode -s bios-version)
|
||||
$RelDate = (sudo dmidecode -s bios-release-date)
|
||||
Write-Host "✅ $Model BIOS by $Manufacturer ($Version release of $RelDate)"
|
||||
Write-Host "✅ BIOS $Model by $Manufacturer ($Version release of $RelDate)"
|
||||
}
|
||||
Write-Progress -completed "."
|
||||
} else {
|
||||
Write-Progress "⏳ Querying BIOS..."
|
||||
$BIOS = Get-CimInstance -ClassName Win32_BIOS
|
||||
$Model = $BIOS.Name.Trim()
|
||||
$Manufacturer = $BIOS.Manufacturer.Trim()
|
||||
$Serial = $BIOS.SerialNumber.Trim()
|
||||
$Version = $BIOS.Version.Trim()
|
||||
Write-Host "✅ $Model BIOS by $Manufacturer (S/N $Serial, version $Version)"
|
||||
Write-Progress -completed "."
|
||||
Write-Host "✅ BIOS $Model by $Manufacturer (S/N $Serial, version $Version)"
|
||||
}
|
||||
Write-Progress -completed "BIOS query finished."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -7,7 +7,7 @@
|
||||
Specifies the minimum warning level (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-drives
|
||||
✅ Drive C uses 87GB of 249GB
|
||||
✅ C drive uses 87GB of 249GB
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -34,7 +34,8 @@ function Bytes2String { param([int64]$Bytes)
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Querying drives..."
|
||||
$Drives = Get-PSDrive -PSProvider FileSystem
|
||||
$Drives = Get-PSDrive -PSProvider FileSystem
|
||||
Write-Progress -completed "done."
|
||||
foreach($Drive in $Drives) {
|
||||
$ID = $Drive.Name
|
||||
$Details = (Get-PSDrive $ID)
|
||||
@ -43,18 +44,17 @@ try {
|
||||
[int64]$Total = ($Used + $Free)
|
||||
|
||||
if ($Total -eq 0) {
|
||||
Write-Host "✅ Drive $ID is empty"
|
||||
Write-Host "✅ $ID drive is empty"
|
||||
} elseif ($Free -eq 0) {
|
||||
Write-Host "⚠️ Drive $ID with $(Bytes2String $Total) is full!"
|
||||
Write-Host "⚠️ $ID drive with $(Bytes2String $Total) is full!"
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
Write-Host "⚠️ Drive $ID with $(Bytes2String $Total) is nearly full ($(Bytes2String $Free) free)!"
|
||||
Write-Host "⚠️ $ID drive with $(Bytes2String $Total) is nearly full ($(Bytes2String $Free) free)!"
|
||||
} elseif ($Used -lt $Free) {
|
||||
Write-Host "✅ Drive $ID uses $(Bytes2String $Used) of $(Bytes2String $Total)"
|
||||
Write-Host "✅ $ID drive uses $(Bytes2String $Used) of $(Bytes2String $Total)"
|
||||
} else {
|
||||
Write-Host "✅ Drive $ID has $(Bytes2String $Free) of $(Bytes2String $Total) free"
|
||||
Write-Host "✅ $ID drive has $(Bytes2String $Free) of $(Bytes2String $Total) free"
|
||||
}
|
||||
}
|
||||
Write-Progress -completed "Querying drives finished."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user