PowerShell/Scripts/check-bios.ps1

40 lines
1.2 KiB
PowerShell
Raw Normal View History

2022-11-14 13:33:53 +01:00
<#
.SYNOPSIS
2023-04-11 10:48:59 +02:00
Checks the BIOS status
2022-11-14 13:33:53 +01:00
.DESCRIPTION
2023-01-23 14:04:23 +01:00
This PowerShell script queries the BIOS status and prints it.
2022-11-14 13:33:53 +01:00
.EXAMPLE
PS> ./check-bios
2023-04-11 10:48:59 +02:00
BIOS F6 by American Megatrends Inc. (version ALASKA - 1072009, S/N NXA82EV0EBB0760)
2022-11-14 13:33:53 +01:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
Write-Progress "⏳ Querying BIOS..."
2022-12-28 11:04:21 +01:00
$Model = (sudo dmidecode -s system-product-name)
2022-12-31 19:33:18 +01:00
if ("$Model" -ne "") {
$Manufacturer = (sudo dmidecode -s system-manufacturer)
$Version = (sudo dmidecode -s bios-version)
$RelDate = (sudo dmidecode -s bios-release-date)
Write-Host "✅ BIOS $Model by $Manufacturer ($Version release of $RelDate)"
2022-12-31 19:33:18 +01:00
}
Write-Progress -completed "."
2022-11-14 13:33:53 +01:00
} else {
Write-Progress "⏳ Querying BIOS..."
2022-11-14 13:33:53 +01:00
$BIOS = Get-CimInstance -ClassName Win32_BIOS
$Model = $BIOS.Name.Trim()
2022-12-28 11:04:21 +01:00
$Manufacturer = $BIOS.Manufacturer.Trim()
$Serial = $BIOS.SerialNumber.Trim()
$Version = $BIOS.Version.Trim()
Write-Progress -completed "."
2023-04-11 10:48:59 +02:00
Write-Host "✅ BIOS $Model by $Manufacturer (version $Version, S/N $Serial)"
2022-11-14 13:33:53 +01:00
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
2023-01-23 14:04:23 +01:00
}