PowerShell/Docs/check-bios.md
2023-08-06 21:36:33 +02:00

2.0 KiB

check-bios.ps1

This PowerShell script queries the BIOS status and prints it.

Parameters

PS> ./check-bios.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

Example

PS> ./check-bios.ps1
 BIOS model F6 version ALASKA - 1072009 by American Megatrends Inc.

Notes

Author: Markus Fleschutz | License: CC0

https://github.com/fleschutz/PowerShell

Script Content

<#
.SYNOPSIS
	Checks the BIOS status
.DESCRIPTION
	This PowerShell script queries the BIOS status and prints it.
.EXAMPLE
	PS> ./check-bios.ps1
	✅ BIOS model F6 version ALASKA - 1072009 by American Megatrends Inc.
.LINK
	https://github.com/fleschutz/PowerShell
.NOTES
	Author: Markus Fleschutz | License: CC0
#>

try {
	if ($IsLinux) {
		Write-Progress "⏳ Querying BIOS details..."
		$Model = (sudo dmidecode -s system-product-name)
		if ("$Model" -ne "") {
			$Version = (sudo dmidecode -s bios-version)
			$RelDate = (sudo dmidecode -s bios-release-date)
			$Manufacturer = (sudo dmidecode -s system-manufacturer)
			Write-Host "✅ BIOS model $Model version $Version of $RelDate by $Manufacturer"
		}
		Write-Progress -completed "."
	} else {
		$BIOS = Get-CimInstance -ClassName Win32_BIOS
		$Model = $BIOS.Name.Trim()
		$Version = $BIOS.Version.Trim()
		$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"
		}
	}
	exit 0 # success
} catch {
	"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
	exit 1
}

(generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1 as of 08/06/2023 21:36:05)