Last active
May 23, 2018 00:22
-
-
Save dstreefkerk/05d88003eeb2b7f2d66b51c6f62ac23a to your computer and use it in GitHub Desktop.
Retrieves all current BIOS settings, and lists possible values for each setting
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
$currentSettings = Get-WmiObject -Class Lenovo_BiosSetting -Namespace root\wmi -Filter 'CurrentSetting != ""' | Select-Object -ExpandProperty CurrentSetting | Sort-Object | |
$allSettings = @() | |
foreach ($setting in $currentSettings) { | |
# Check if Lenovo_GetBiosSelections exists. If not, we're running on a newer system that includes returns the possible values | |
# as part of the current setting value | |
$legacyMethodExists = Get-CimClass Lenovo_GetBiosSelections -Namespace root\wmi -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | |
if ($legacyMethodExists) { | |
$settingName = $setting.split(',')[0] | |
$settingValue = $setting.split(',')[1] | |
$possibleSelections = (Get-WmiObject -Class Lenovo_GetBiosSelections -Namespace root\wmi).GetBiosSelections($settingName) | Select-Object -ExpandProperty Selections | |
} else { | |
$settingName = $setting.split(',')[0] | |
$settingValue = ($setting.split(';')[0]).split(',')[1] | |
$possibleSelections = $setting.split(';')[1] | |
} | |
$settingHashTable = [ordered]@{'Setting' = $settingName;'Value' = $settingValue;'PossibleSelections' = $possibleSelections} | |
$allSettings += New-Object -TypeName psobject -Property $settingHashTable | |
} | |
$product = Get-WmiObject Win32_ComputerSystemProduct | |
$allSettings | Out-GridView -Title "Bios settings for $($product.Vendor) $($product.Version) ($($product.Name))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment