Working in the Datacenter – Deploying HP Servers and configure BIOS for High Performance using PowerShell

If you have a HP ProLiant Gen 8 or Gen 9 it is possible to use PowerShell to configure the BIOS. One of the items I really like to configure is the Power Settings, in most cases you would like to have “performance” but the default setting is usually set in “Tree Hugging Mode” (also called power saving). This is especially true if server is going to be used as a Compute server (running Hyper-V).

You can read the previous posts here:



The Script:

 Install Wrapper 1.0
 Author: Mikael Nystrom
Function Invoke-Exe{



    if($Arguments -eq "")
        Write-Verbose "Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru"
        $ReturnFromEXE = Start-Process -FilePath $Executable -NoNewWindow -Wait -Passthru
        Write-Verbose "Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru"
        $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru
    Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)"
    Return $ReturnFromEXE.ExitCode
Function Get-OSVersion([ref]$OSv){
    $OS = Get-WmiObject -class Win32_OperatingSystem
    Switch -Regex ($OS.Version)
        {If($OS.ProductType -eq 1)
            {$OSv.value = "Windows 7 SP1"}
            {$OSv.value = "Windows Server 2008 R2"}
        {If($OS.ProductType -eq 1)
            {$OSv.value = "Windows 8"}
            {$OSv.value = "Windows Server 2012"}
        {If($OS.ProductType -eq 1)
            {$OSv.value = "Windows 8.1"}
            {$OSv.value = "Windows Server 2012 R2"}
    DEFAULT { "Version not listed" }
Function Import-SMSTSENV{
        $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
        Write-Output "$ScriptName - tsenv is $tsenv "
        $MDTIntegration = "YES"
        #$tsenv.GetVariables() | % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" }
        Write-Output "$ScriptName - Unable to load Microsoft.SMS.TSEnvironment"
        Write-Output "$ScriptName - Running in standalonemode"
        $MDTIntegration = "NO"
    if ($MDTIntegration -eq "YES"){
        $Logpath = $tsenv.Value("LogPath")
        $LogFile = $Logpath + "\" + "$ScriptName.log"

        $Logpath = $env:TEMP
        $LogFile = $Logpath + "\" + "$ScriptName.log"
Function Start-Logging{
    start-transcript -path $LogFile -Force
Function Stop-Logging{

# Set Vars
$SCRIPTDIR = split-path -parent $MyInvocation.MyCommand.Path
$SCRIPTNAME = split-path -leaf $MyInvocation.MyCommand.Path
$LANG = (Get-Culture).Name
$OSV = $Null

#Try to Import SMSTSEnv

#Start Transcript Logging
. Start-Logging

#Detect current OS Version
. Get-OSVersion -osv ([ref]$osv) 

#Output base info
Write-Output ""
Write-Output "$ScriptName - ScriptDir: $ScriptDir"
Write-Output "$ScriptName - SourceRoot: $SOURCEROOT"
Write-Output "$ScriptName - ScriptName: $ScriptName"
Write-Output "$ScriptName - OS Name: $osv"
Write-Output "$ScriptName - OS Architecture: $ARCHITECTURE"
Write-Output "$ScriptName - Current Culture: $LANG"
Write-Output "$ScriptName - Integration with MDT(LTI/ZTI): $MDTIntegration"
Write-Output "$ScriptName - Log: $LogFile"

$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList "$env:COMPUTERNAM\$UserName", ($Password | ConvertTo-SecureString -AsPlainText -Force)
$Con = Connect-HPBIOS -IP $env:COMPUTERNAME -Credential $Credentials -ErrorAction Stop

Write-Output "$ScriptName -  Selected Mode: $Mode"

if($mode -eq "FullPower"){
    Set-HPBIOSPowerProfile -Profile Maximum_Performance -Connection $Con
    Set-HPBIOSPowerRegulator -Regulator Static_High_Performance -Connection $Con
    Write-Output "$ScriptName - HP PowerProfile is set to $((Get-HPBIOSPowerProfile -Connection $Con).HPPowerProfile)"
    Write-Output "$ScriptName - HP PowerRegulator is set to $((Get-HPBIOSPowerRegulator -Connection $Con).HPPowerRegulator)"

if($mode -eq "TreeHugging"){
    Set-HPBIOSPowerProfile -Profile Minimum_Power -Connection $Con
    Set-HPBIOSPowerRegulator -Regulator Dynamic_Power_Savings -Connection $Con
    Write-Output "$ScriptName - HP PowerProfile is set to $((Get-HPBIOSPowerProfile -Connection $Con).HPPowerProfile)"
    Write-Output "$ScriptName - HP PowerRegulator is set to $((Get-HPBIOSPowerRegulator -Connection $Con).HPPowerRegulator)"

. Stop-Logging

Using the script from the command prompt:

Execute the following from an elevated Command Prompt

PowerShell.exe -ExecutionPolicy ByPass -File Configure-HPBIOS.ps1 -Mode FullPower -UserName Administrator –Password P@ssw0rd

Using the script from the PowerShell prompt:

Execute the following from an elevated PowerShell Prompt

.\Configure-HPBIOS.ps1 -Mode FullPower -UserName Administrator –Password P@ssw0rd

Using the script in a Task Sequence when you deploy the server:

You can run the script as PowerShell script in the Task Sequence, or run it as an Application. I prefer to use it as an application since it then can be controlled using rules.

The Config-HPBios application:

Here you can see the Quiet install command in the application.

Quiet install command: PowerShell.exe -ExecutionPolicy ByPass -File Configure-HPBIOS.ps1 -Mode %HPPowerMode% -UserName Administrator -Password %AdminPassword%

This command will execute PowerShell and feed the script with Property HPPowerMode (that needs to be FullPower or TreeHugging). This property can be set in CustomSettings.ini or as step in the Task Sequence.

Here you can see the Set Task Sequence Variable HPPowerMode set to FullPower.

The actually configuration will be done during the Install step, since it is an application in my case. but it is possible to run the app directly after the Variable has been set.

Check the log file for the result:

The log file shows the settings.


1 reply »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.