PowerShell/Scripts/check-bios.ps1
2022-12-31 19:33:18 +01:00

39 lines
1.1 KiB
PowerShell

<#
.SYNOPSIS
Checks BIOS details
.DESCRIPTION
This PowerShell script queries and prints BIOS details.
.EXAMPLE
PS> ./check-bios
✅ F6 BIOS by American Megatrends Inc. (S/N NXA82EV0EBB0760, version ALASKA - 1072009)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
Write-Progress "Querying BIOS details..."
if ($IsLinux) {
$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)
"$Model BIOS by $Manufacturer ($Version release of $RelDate)"
}
} else {
$BIOS = Get-CimInstance -ClassName Win32_BIOS
$Model = $BIOS.Name.Trim()
$Manufacturer = $BIOS.Manufacturer.Trim()
$Serial = $BIOS.SerialNumber.Trim()
$Version = $BIOS.Version.Trim()
"$Model BIOS by $Manufacturer (S/N $Serial, version $Version)"
}
Write-Progress -Completed " "
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}