-
×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
- Archived Topics
- Desktops (Archived)
- Get / Set HP BIOS with PowerShell

Create an account on the HP Community to personalize your profile and ask a question

05-24-2015 04:18 AM
Hello,
We have about 3.500 HP workstations. We have 6 different models: HP Compaq 8000/8100/8200/8300 Elite, HP Compaq 6005 Pro and HP ProDesk 600 G1. As it turns out some of the workstations have the wrong boot order. Boot order must be: 1 - Network, 2 Hard Drive and some workstations have 1 - Hard Drive , 2 - Network. I want to correct this with PowerShell. I'm trying to read and set the Boot Order in the BIOS in Windows 8.1 Enterprise. These workstations are not up to date (Update 1 not installed) and we want to give all those 3.500 workstation a new ZENwork Windows 8.1 Update 1 image in Juli but the first boot must be Network otherwise it won't work. The next weeks we want to correct this boot order in the login script.
I don't want to use the BiosConfigUtility64.exe, well I have to use this if this PowerShell code does not work. This is the code I have so far:
#The correct settings string for each HP Model
#HP Compaq 8000/8100 Elite:
$strBootSetting1="Network Controller,Hard Drive,USB device,ATAPI CD-ROM Drive Disabled,Diskette Drive,PnP Device #2,PnP Device #3,PnP Device #4,PnP Device #5,PnP Device #6,PnP Device #7,PnP Device #8,PnP Device #9,PnP Device #10"
#HP Compaq 6005 Pro
$strBootSetting2="Network Controller,Hard Drive,USB device,ATAPI CD-ROM Drive Disabled,Diskette Drive,PnP Device #2,PnP Device #3,PnP Device #4,PnP Device #5,PnP Device #6,PnP Device #7,PnP Device #8,PnP Device #9,PnP Device #10,PnP Device #11"
#HP Compaq 8200 Elite / HP Compaq Elite 8300 / HP ProDesk 600 G1
$strBootSetting3="Network Controller,Hard Drive,USB Floppy/CD,ATAPI CD-ROM Drive,PnP Device #1,PnP Device #2,PnP Device #3,PnP Device #4,PnP Device #5,PnP Device #6,PnP Device #7,PnP Device #8,PnP Device #9,PnP Device #10,PnP Device #11"
#HP Models we have
$strModelHP8000="HP Compaq 8000 Elite"
$strModelHP6005="HP Compaq 6005 Pro"
$strModelHP8100="HP Compaq 8100 Elite"
$strModelHP8200="HP Compaq 8200 Elite"
$strModelHP8300="HP Compaq Elite 8300"
$strModelHP600G="HP ProDesk 600 G1"
$strBootOrder=""
$strModel=$(Get-WmiObject Win32_ComputerSystem).Model
#Not every model has the same BIOS setting name. It is "Boot Order" or "Legacy Boot Order"
if ($strModel.SubString( 0, 18) -eq $strModelHP6005 ) {
echo "Yes: $strModelHP6005"
$strBootOrder="Boot Order"
$strBootSetting=$strBootSetting2
}
elseif ($strModel.SubString( 0, 20) -eq $strModelHP8000 ) {
echo "Yes: $strModelHP8000"
$strBootOrder="Boot Order"
$strBootSetting=$strBootSetting1
}
elseif ($strModel.SubString( 0, 20) -eq $strModelHP8100 ) {
echo "Yes: $strModelHP8100"
$strBootOrder="Boot Order"
$strBootSetting=$strBootSetting1
}
elseif ($strModel.SubString( 0, 20) -eq $strModelHP8200 ) {
echo "Yes: $strModelHP8200"
$strBootOrder="Legacy Boot Order"
$strBootSetting=$strBootSetting3
}
elseif ($strModel.SubString( 0, 20) -eq $strModelHP8300 ) {
echo "Yes: $strModelHP8300"
$strBootOrder="Legacy Boot Order"
$strBootSetting=$strBootSetting3
}
elseif ($strModel.SubString( 0, 17) -eq $strModelHP600G ) {
echo "Yes: $strModelHP600G"
$strBootOrder="Legacy Boot Order"
$strBootSetting=$strBootSetting3
}
$objWMI = Get-WmiObject -class HP_BIOSSetting -Namespace "root\HP\InstrumentedBIOS" | Where Name -eq "$strBootOrder"
$strBootOrderValue=$objWMI.GetPropertyValue( "Value" )
if ( -not ($strBootOrderValue.SubString( 0, 29) -eq "Network Controller,Hard Drive" ) ) {
$objWMI.SetBIOSSetting( "$strBootOrder", "$strBootSetting", "<utf-16/>PASSWORD" )
}
Everywhere on internet I see the .SetBIOSSetting function but on our HP systems I get the error message "Method invocation failed because [System.Management.ManagmentObject] does not contain a method named 'SetBIOSSetting'."
$objWMI.SetPropertyValue( $strBootOrder, $strBootSetting ) does work. When you give the command$objWMI.GetPropertyValue( "Value" ) we get the value we just set with SetPropertyValue. The problem is that is does not get saved back to the BIOS.
What can I do to solve this or must I use the BiosConfigUtility64.exe tools? why do I not have the SetBIOSSetting option?
Best regards,
Diederick Cools
07-09-2015 10:22 AM
Using WMI Explorer, I can see that HPBIOS_BIOSSetting has no methods. I beleive you should be using HPBIOS_BIOSSettingInterface for your class here:
$objWMI = Get-WmiObject -class HP_BIOSSetting -Namespace
I didn't to try to do this with PowerShell. I'm not a domain admin but I am a local admin on all my PCs. I have an Excel workbook with all my company's hostnames, so I just used VBA. Here's my sub for setting the Asset Tag. Hopefullly it helps.
Sub SetBIOSAssetTag() Dim strCmd As String Dim strComputer As String Dim strAssetTag As String Dim strSN As String Dim strPassword As String Dim strReturn As String Dim strName As String Dim r As Integer Dim c As Integer Dim x As Integer Dim objSWbemLocator Dim objWMIService Dim objShare Dim objInParam Dim objOutParams Dim colItems Dim objItem Dim objFSO As New FileSystemObject r = ActiveCell.Row c = ActiveCell.Column strComputer = ActiveSheet.Cells(r, 2).Text strAssetTag = ActiveSheet.Cells(r, 5).Text strSN = ActiveSheet.Cells(r, 6).Text If Not objFSO.FolderExists("\\" & ActiveSheet.Cells(r, 2).Text & "\c$\") Then MsgBox "This PC appears to be offline", vbCritical, "PC Offline" Exit Sub End If On Error GoTo ErrorOccured 'ask the user for password frmBIOSPassword.Show vbModal strPassword = frmBIOSPassword.txtBIOSPassword.Value Unload frmBIOSPassword If strPassword = "<input was cancelled>" Then Exit Sub 'show the user we're working Application.Cursor = xlWait 'Enable Remote WMI in the firewall strCmd = "winrs -r:" & strComputer & " netsh advfirewall firewall set rule group=" & Chr(34) & "Windows Management Instrumentation (WMI)" & Chr(34) & " new enable=yes" Shell "cmd.exe /S /C" & strCmd, vbNormalFocus Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\HP\InstrumentedBIOS") 'We have to search for the exact bios tag name because it varies by model Set colItems = objWMIService.ExecQuery("SELECT * FROM HPBIOS_BIOSString", , 48) For Each objItem In colItems If InStr(1, objItem.Name, "Asset") Then strName = objItem.Name Next ' Obtain an instance of the the class using a key property value. Set objShare = objWMIService.Get("HPBIOS_BIOSSettingInterface.InstanceName='ACPI\PNP0C14\0_0'") ' Obtain an InParameters object specific to the method. Set objInParam = objShare.Methods_("SetBIOSSetting").InParameters.SpawnInstance_() ' Add the input parameters. objInParam.Properties_.Item("Name") = strName objInParam.Properties_.Item("Value") = strAssetTag objInParam.Properties_.Item("Password") = "<utf-16/>" & strPassword ' Execute the method and obtain the return status. ' The OutParameters object in objOutParams is created by the provider. Set objOutParams = objWMIService.ExecMethod("HPBIOS_BIOSSettingInterface.InstanceName='ACPI\PNP0C14\0_0'", "SetBIOSSetting", objInParam) Select Case objOutParams.Return Case 0 strReturn = "Success. Asset Tag " & strAssetTag & " will be configured the next time you reboot " & strComputer & "." Case 1 strReturn = "1: Not Supported" Case 2 strReturn = "2: Unspecified Error" Case 3 strReturn = "3: Timeout" Case 4 strReturn = "4: Failed" Case 5 strReturn = "5: Invalid Parameter" Case 6 strReturn = "6: Access Denied" Case Else strReturn = "..." End Select ErrorOccured: strReturn = strReturn & vbCrLf & Err.Number & " " & Err.Description Application.Cursor = xlDefault MsgBox "Return: " & strReturn 'Disable remote WMI for security reasons strCmd = "winrs -r:" & strComputer & " netsh advfirewall firewall set rule group=" & Chr(34) & "Windows Management Instrumentation (WMI)" & Chr(34) & " new enable=no" Shell "cmd.exe /S /C" & strCmd, vbNormalFocus Set objSWbemLocator = Nothing Set objWMIService = Nothing Set colItems = Nothing Set objShare = Nothing Set objInParam = Nothing Set objOutParams = Nothing End Sub
