Change from BIOS to UEFI during SCCM Task Sequence (Lenovo PC’s) with Powershell

When you need to change the UEFI settings like SecureBoot – or other settings – with PowerShell, this script here can be handy. You define the settings for your needs in the $ DesiredSettings variable

<#

    .SYNOPSIS
   
    .DESCRIPTION

    .PARAMETER

    .EXAMPLE

    .NOTES
    Author: Morten Rnborg
    Date: 10-09-2018
    Last Updated: 03-02-2019
    https://mroenborg.com
#>

################################################

#Variables
$CurrentSettings = (Get-WmiObject -class Lenovo_BiosSetting -namespace root\wmi).CurrentSetting
$DesiredSettings = @("SecureBoot,Enable", "WakeOnLAN,ACOnly")

#Check and set settings 
ForEach($DesiredSetting in $DesiredSettings){

    if($DesiredSetting -in $CurrentSettings){

        #If already configreud, skip
        Write-Host "'$DesiredSetting' is already set, skipping..."
    }Else{

        #Set the setting
        Write-Host "'$DesiredSetting' is not set, configuring..."
        Get-WmiObject -Class Lenovo_SetBiosSetting($DesiredSetting)
    }
}

#Save the settings
(Get-WmiObject -Class Lenovo_SaveBiosSettings -namespace root\wmi).SaveBiosSettings()

Read more about your options here: https://support.lenovo.com/dk/da/documents/ht100612

Leave a comment if you have any questions!
Thanks

Leave a comment