PowerShell/Scripts/check-bios.ps1

42 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-08-06 18:48:56 +02:00
BIOS model F6 version ALASKA - 1072009 by American Megatrends Inc.
2022-11-14 13:33:53 +01:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
2023-08-06 18:48:56 +02:00
Write-Progress "⏳ Querying BIOS details..."
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 "") {
$Version = (sudo dmidecode -s bios-version)
$RelDate = (sudo dmidecode -s bios-release-date)
2023-08-06 18:48:56 +02:00
$Manufacturer = (sudo dmidecode -s system-manufacturer)
Write-Host "✅ BIOS model $Model version $Version of $RelDate by $Manufacturer"
2022-12-31 19:33:18 +01:00
}
Write-Progress -completed "."
2022-11-14 13:33:53 +01:00
} else {
$BIOS = Get-CimInstance -ClassName Win32_BIOS
$Model = $BIOS.Name.Trim()
$Version = $BIOS.Version.Trim()
2023-08-06 18:48:56 +02:00
$Serial = $BIOS.SerialNumber.Trim()
$Manufacturer = $BIOS.Manufacturer.Trim()
if ($Serial -eq "To be filled by O.E.M.") {
Write-Host "✅ BIOS model $Model version $Version by $Manufacturer"
} else {
Write-Host "✅ BIOS model $Model version $Version, S/N $Serial, by $Manufacturer"
}
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
}