PowerShell/Scripts/check-bios.ps1

43 lines
1.3 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
2023-08-06 21:35:36 +02:00
PS> ./check-bios.ps1
2023-08-21 17:06:42 +02:00
BIOS model P62 v02.67 by HP (version HPQOEM - 5, S/N CZC1080B01)
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 by $manufacturer (version $version of $releaseDate)"
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()
$serialNumber = $BIOS.SerialNumber.Trim()
$manufacturer = $BIOS.Manufacturer.Trim()
if ($serialNumber -eq "To be filled by O.E.M.") {
Write-Host "✅ BIOS model $model by $manufacturer (version $version)"
2023-08-06 18:48:56 +02:00
} else {
2023-08-21 17:06:42 +02:00
Write-Host "✅ BIOS model $model by $manufacturer (version $version, S/N $serialNumber)"
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
}