PowerShell/Scripts/check-bios.ps1

38 lines
1.1 KiB
PowerShell
Raw Normal View History

2022-11-14 13:33:53 +01:00
<#
.SYNOPSIS
2023-01-23 14:04:23 +01:00
Checks the BIOS
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
2022-12-28 10:42:38 +01:00
F6 BIOS by American Megatrends Inc. (S/N NXA82EV0EBB0760, version ALASKA - 1072009)
2022-11-14 13:33:53 +01:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
2023-01-23 14:04:23 +01:00
Write-Progress "⏳ Querying BIOS details..."
2022-11-14 13:33:53 +01:00
if ($IsLinux) {
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)
2023-01-03 10:56:05 +01:00
Write-Host "$Model BIOS by $Manufacturer ($Version release of $RelDate)"
2022-12-31 19:33:18 +01:00
}
2022-11-14 13:33:53 +01:00
} else {
$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()
2023-01-03 10:56:05 +01:00
Write-Host "$Model BIOS by $Manufacturer (S/N $Serial, version $Version)"
2022-11-14 13:33:53 +01:00
}
2023-01-23 14:04:23 +01:00
Write-Progress -completed "BIOS query finished."
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
}