Re: BIOS configuration using Powershell
Hello,
I've taken some time to try and configure something in powershell to help with my BIOS configs. It is currently working under the administrator account on the Win7 laptop I'm testing on, but I'm having issues getting it running under system (for deployment with SCCM). We have a bios password set on all our machines as well, so it will enter that in.
To use this script you need another file to contain all the settings you wish to use. It will be structured like LockBIOSSetting,Enable with each setting on a new line. it can be called anything you want, i'll use settings.txt.
Run with these paramaters %scriptname%.ps1 -password %biospassword% -file settings.txt
If anyone has any suggestions on running as system account, I would greatly appreciate it. I'm currently launching it useing powershell.exe -executionPolicy bypass -Noninteractive -Noprofile -file %script%.ps1 -password %password% -file LockBIOSSetting-enable.txt
param( [Parameter(Mandatory=$true,Position=1)] [string]$password, [Parameter(Mandatory=$true,Position=2)] [array]$file ) $settings = Get-Content $file foreach($setting in $settings){ $run = "$setting,$password,ascii,us" write-output $run $Responce = (gwmi -class Lenovo_SetBiosSetting -namespace root\wmi).SetBiosSetting("$run").return $Responce if(-not (gwmi -class Lenovo_BiosSetting -namespace root\wmi | Where-Object {$_.CurrentSetting -eq $setting})){ $errorarray += "$setting" $errorarray += "," $errorarray += $Responce $errorarray += "`r`n" } } if($errorarray -ne $null){ foreach($errorname in $errorarray){ $errorname | out-file "error.txt" throw 666 } }