Created
December 11, 2020 19:30
-
-
Save mavericksevmont/df694b9665094e0a68e875bfb904ff0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Regex 1: https://regex101.com/r/Y3HJSf/2 | |
# Regex 2: https://regex101.com/r/DQ9H7b/2 | |
#Table | |
$Settings = ( | |
"HP EliteBook 830 G5,01.11.01", | |
"HP EliteBook 840 G5,01.11.01", | |
"HP EliteBook 840 G6,01.05.03", | |
"HP EliteBook x360 1030 G2,01.34", | |
"HP EliteBook x360 1030 G3,01.11.01", | |
"HP EliteBook x360 1030 G4,01.05.03", | |
"HP EliteBook 1040 G4,01.34", | |
"HP ZBook 15 G5,01.11.02" | |
) | |
$MachineModel = (Get-WmiObject -Class Win32_ComputerSystem).Model # computer model | |
$wmiBIOS = (Get-WmiObject -Class Win32_BIOS).SMBIOSBIOSVersion # wmi query for computer's BIOS info | |
$wmiBIOS -match '\d+\.\d+\.*\d+' | Out-Null # regex to match BIOS version number only | |
$MachineBIOS = $matches.Values # BIOS version, number only | |
$MatchedModel = $Settings -match $MachineModel # Find if MachineModel exists in the Settings Table | |
# Parse model and Bios from table if match was found | |
if ($MatchedModel) { | |
$TableModel = $MatchedModel.split(',')[0] # Split Model from match | |
$TableBIOS = $MatchedModel.split(',')[1] # Split Bios version from match | |
} else {"No Model matches found";break} # If no match, stop the script | |
# Compare if Machine's BIOS ver is greater or equal than the Settings BIOS ver | |
if ($MachineBIOS -ge $TableBIOS) {"$MachineBIOS is greater or equal than $TableBIOS"} | |
else {"$MachineBIOS is less than $TableBIOS"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment