-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
- HP Community
- Notebooks
- Notebook Operating System and Recovery
- Powershell Command to Make Changes in BIOS

Create an account on the HP Community to personalize your profile and ask a question
06-09-2014 01:20 PM
Two things i need please.
- the list of models manageable by WMI (if not all)
- assistance with getting the following to work when there is a BIOS password set
You help is appreciated.
I am trying to use WMI to make some changes to the BIOS on various laptop models. Those without a password can be set and the commands work beautifully, like so....
$BIOS= gwmi -CN $ComputerName -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$BIOS= gwmi -CN $ComputerName -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$BIOS.SetBIOSSetting("Numlock state at boot","On","$BIOS_PW")
I have tried with and without <kbd/> coding to accomodate the possibility of hex password.
$BIOS= gwmi -CN $ComputerName -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$BIOS.SetBIOSSetting("Numlock state at boot","On","<kbd/>$BIOS_PW")
and have also tried the following function that i've seen used in a few people's code to convert the pw string to hex before implementing the SetBIOSSetting command, but still no joy.
function Convert-ToKbdString
{
[CmdletBinding()]
[OutputType([string])]
Param
(
# Input, Type string, String to be encoded with EN Keyboard Scan Code Hex Values.
[Parameter(Mandatory=$true,
Position=0)]
[string]
$UTF16String
)
$kbdHexVals=New-Object System.Collections.Hashtable
$kbdHexVals."a"="1E"
$kbdHexVals."b"="30"
$kbdHexVals."c"="2E"
$kbdHexVals."d"="20"
$kbdHexVals."e"="12"
$kbdHexVals."f"="21"
$kbdHexVals."g"="22"
$kbdHexVals."h"="23"
$kbdHexVals."i"="17"
$kbdHexVals."j"="24"
$kbdHexVals."k"="25"
$kbdHexVals."l"="26"
$kbdHexVals."m"="32"
$kbdHexVals."n"="31"
$kbdHexVals."o"="18"
$kbdHexVals."p"="19"
$kbdHexVals."q"="10"
$kbdHexVals."r"="13"
$kbdHexVals."s"="1F"
$kbdHexVals."t"="14"
$kbdHexVals."u"="16"
$kbdHexVals."v"="2F"
$kbdHexVals."w"="11"
$kbdHexVals."x"="2D"
$kbdHexVals."y"="15"
$kbdHexVals."z"="2C"
$kbdHexVals."A"="9E"
$kbdHexVals."B"="B0"
$kbdHexVals."C"="AE"
$kbdHexVals."D"="A0"
$kbdHexVals."E"="92"
$kbdHexVals."F"="A1"
$kbdHexVals."G"="A2"
$kbdHexVals."H"="A3"
$kbdHexVals."I"="97"
$kbdHexVals."J"="A4"
$kbdHexVals."K"="A5"
$kbdHexVals."L"="A6"
$kbdHexVals."M"="B2"
$kbdHexVals."N"="B1"
$kbdHexVals."O"="98"
$kbdHexVals."P"="99"
$kbdHexVals."Q"="90"
$kbdHexVals."R"="93"
$kbdHexVals."S"="9F"
$kbdHexVals."T"="94"
$kbdHexVals."U"="96"
$kbdHexVals."V"="AF"
$kbdHexVals."W"="91"
$kbdHexVals."X"="AD"
$kbdHexVals."Y"="95"
$kbdHexVals."Z"="AC"
$kbdHexVals."1"="02"
$kbdHexVals."2"="03"
$kbdHexVals."3"="04"
$kbdHexVals."4"="05"
$kbdHexVals."5"="06"
$kbdHexVals."6"="07"
$kbdHexVals."7"="08"
$kbdHexVals."8"="09"
$kbdHexVals."9"="0A"
$kbdHexVals."0"="0B"
$kbdHexVals."!"="82"
$kbdHexVals."@"="83"
$kbdHexVals."#"="84"
$kbdHexVals."$"="85"
$kbdHexVals."%"="86"
$kbdHexVals."^"="87"
$kbdHexVals."&"="88"
$kbdHexVals."*"="89"
$kbdHexVals."("="8A"
$kbdHexVals.")"="8B"
$kbdHexVals."-"="0C"
$kbdHexVals."_"="8C"
$kbdHexVals."="="0D"
$kbdHexVals."+"="8D"
$kbdHexVals."["="1A"
$kbdHexVals."{"="9A"
$kbdHexVals."]"="1B"
$kbdHexVals."}"="9B"
$kbdHexVals.";"="27"
$kbdHexVals.":"="A7"
$kbdHexVals."'"="28"
$kbdHexVals."`""="A8"
$kbdHexVals."``"="29"
$kbdHexVals."~"="A9"
$kbdHexVals."\"="2B"
$kbdHexVals."|"="AB"
$kbdHexVals.","="33"
$kbdHexVals."<"="B3"
$kbdHexVals."."="34"
$kbdHexVals.">"="B4"
$kbdHexVals."/"="35"
$kbdHexVals."?"="B5"
$kbdEncodedString=""
foreach ($char in $UTF16String.ToCharArray())
{
$kbdEncodedString+=$kbdHexVals.Get_Item($char.ToString())
}
return $kbdEncodedString
}
Solved! Go to Solution.
Accepted Solutions
06-09-2014 02:31 PM
NVM...I got it.
using the function Convert-ToKbdString
as well as the following
$BIOS= gwmi -CN $ComputerName -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$BIOS.SetBIOSSetting("Numlock state at boot","On","<kbd/>$BIOS_PW")
we come up with
$BIOS_PW="<kbd/>"+(Convert-ToKbdString -UTF16String "ThePassword")
$BIOS= gwmi -CN $ComputerName -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$BIOS.SetBIOSSetting("Numlock state at boot","On","$BIOS_PW")
So it turns out, it's a combination of solutions that worked.
06-09-2014 02:31 PM
NVM...I got it.
using the function Convert-ToKbdString
as well as the following
$BIOS= gwmi -CN $ComputerName -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$BIOS.SetBIOSSetting("Numlock state at boot","On","<kbd/>$BIOS_PW")
we come up with
$BIOS_PW="<kbd/>"+(Convert-ToKbdString -UTF16String "ThePassword")
$BIOS= gwmi -CN $ComputerName -class hp_biossettinginterface -Namespace "root\hp\instrumentedbios"
$BIOS.SetBIOSSetting("Numlock state at boot","On","$BIOS_PW")
So it turns out, it's a combination of solutions that worked.
12-28-2014 03:42 AM
Hello Shanaun,
I am trying to accomplish the similar task but I am not clear about Conver-ToKbdString function. Shall I put this function in Powershell or will it go in seperate file like vb script? If this goes in seperate file, please guide me how can I put this function in seperate file so that this function can be executed from PowerShell ISE.
Can we setup BIOS password using this technique? If so, please let me know how this could be done. I have 200+ Hp computers to setup there BIOS password.
Your help would be highly appreciated.
Faraz Amjad
03-16-2017 10:46 AM
This HP BIOS setting via WMI apparently won't work if your kbd encoded password contains a shifted character like !@#$ etc.
I've tried everything, including the codes for those from your code's hashtable (the unmake for those keys, which is not the same as a shifted value) and none of them work.
I think the issue is because there is no such thing a keyboard scan code for these characters like !@#$ etc. They are combinations of keys and there is nothing in the HP CIM whitepaper that says whether their setbiossetting WMI method accepts combinations of keyboard scan codes to indicate a shifted standard character. So until I see otherwise from HP or a working script example with a shifted (!@#$) character in it, I'm going to assume HP didn't code that in their method so it will never work.
thanks HP