mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-02 04:43:57 +01:00
78 lines
2.0 KiB
Markdown
78 lines
2.0 KiB
Markdown
*check-bios.ps1*
|
|
================
|
|
|
|
This PowerShell script queries the BIOS status and prints it.
|
|
|
|
Parameters
|
|
----------
|
|
```powershell
|
|
PS> ./check-bios.ps1 [<CommonParameters>]
|
|
|
|
[<CommonParameters>]
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
```
|
|
|
|
Example
|
|
-------
|
|
```powershell
|
|
PS> ./check-bios
|
|
✅ BIOS 'F6', release ALASKA - 1072009, S/N NXA82EV0EBB0760 by American Megatrends Inc.
|
|
|
|
```
|
|
|
|
Notes
|
|
-----
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
Related Links
|
|
-------------
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
Script Content
|
|
--------------
|
|
```powershell
|
|
<#
|
|
.SYNOPSIS
|
|
Checks the BIOS status
|
|
.DESCRIPTION
|
|
This PowerShell script queries the BIOS status and prints it.
|
|
.EXAMPLE
|
|
PS> ./check-bios
|
|
✅ BIOS 'F6', release ALASKA - 1072009, S/N NXA82EV0EBB0760 by American Megatrends Inc.
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
.NOTES
|
|
Author: Markus Fleschutz | License: CC0
|
|
#>
|
|
|
|
try {
|
|
if ($IsLinux) {
|
|
Write-Progress "⏳ Querying BIOS..."
|
|
$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)
|
|
Write-Host "✅ BIOS $Model by $Manufacturer ($Version release of $RelDate)"
|
|
}
|
|
Write-Progress -completed "."
|
|
} else {
|
|
# Write-Progress "⏳ Querying BIOS..."
|
|
$BIOS = Get-CimInstance -ClassName Win32_BIOS
|
|
$Model = $BIOS.Name.Trim()
|
|
$Manufacturer = $BIOS.Manufacturer.Trim()
|
|
$Serial = $BIOS.SerialNumber.Trim()
|
|
$Version = $BIOS.Version.Trim()
|
|
# Write-Progress -completed "."
|
|
Write-Host "✅ BIOS '$Model', release $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 11:42:25)*
|