Skip to content

Instantly share code, notes, and snippets.

@dstreefkerk
Last active May 23, 2018 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstreefkerk/05d88003eeb2b7f2d66b51c6f62ac23a to your computer and use it in GitHub Desktop.
Save dstreefkerk/05d88003eeb2b7f2d66b51c6f62ac23a to your computer and use it in GitHub Desktop.
Retrieves all current BIOS settings, and lists possible values for each setting
$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