PowerShell/scripts/check-bios.ps1

43 lines
1.3 KiB
PowerShell
Raw Normal View History

2024-10-01 15:11:03 +02:00
<#
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
2023-08-06 21:35:36 +02:00
PS> ./check-bios.ps1
BIOS model P62 v02.67, version HPQOEM - 5, S/N CZC1080B01 by HP
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 details..."
2023-08-21 17:06:42 +02:00
$model = (sudo dmidecode -s system-product-name)
if ("$model" -ne "") {
$version = (sudo dmidecode -s bios-version)
$releaseDate = (sudo dmidecode -s bios-release-date)
$manufacturer = (sudo dmidecode -s system-manufacturer)
Write-Host "✅ BIOS model $model, version $version of $releaseDate 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
2023-08-21 17:06:42 +02:00
$model = $BIOS.Name.Trim()
$version = $BIOS.Version.Trim()
$serial = $BIOS.SerialNumber.Trim()
2023-08-21 17:06:42 +02:00
$manufacturer = $BIOS.Manufacturer.Trim()
if ($serial -eq "To be filled by O.E.M.") {
Write-Host "✅ BIOS model $model, version $version by $manufacturer"
2023-08-06 18:48:56 +02:00
} else {
Write-Host "✅ BIOS model $model, version $version, S/N $serial by $manufacturer"
2023-08-06 18:48:56 +02:00
}
2022-11-14 13:33:53 +01:00
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
2023-08-06 21:35:36 +02:00
}