Rahul Sharma
Rahul Sharma

Reputation: 190

How do I get the Boot order value on an HP computer

I would like to read out my boot order settings using PowerShell. I can get those with the following script:

$bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class hp_biosSetting
($bios | Where-Object {$_.Name -eq 'Boot Order'}).Value.Split(',')

However, the output I get is not correct. I want just the value, but am getting the value and the name of the setting. For example:

USB Floppy  Disabled

The only thing I could find is to split it with an ,, but I only want the value as output.

Upvotes: 0

Views: 4264

Answers (1)

Rahul Sharma
Rahul Sharma

Reputation: 190

The correct anwser.

   $bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class hp_biosSetting
$bios4 =($bios | Where-Object {$_.Name -eq 'Legacy Boot Order'}).Value.Split(',')
echo $bios4

if ($bios4 -match "ATAPI CD-ROM Drive Disabeld"){
echo "ATAPI CD-ROM Drive =Disabeld"
$qu= "BEGIN INSERT into TESTAAD(Waarde_pcName,WAARDE_CD_ROM_BOOT) VALUES('$Waarde_pcName','Disabeld'); exception when dup_val_on_index THEN UPDATE TESTAAD SET Waarde_CD_ROM_BOOT = 'Disabeld' WHERE Waarde_pcName = '$Waarde_pcName'; END;"
$cmd = $con.CreateCommand()
$cmd.CommandText = $qu
$cmd.ExecuteNonQuery() |out-null
}
    else{
            echo " ATAPI CD-ROM Drive =Enabeld"
            $qu= "BEGIN INSERT into TESTAAD(Waarde_pcName,Waarde_CD_ROM_BOOT) VALUES('$Waarde_pcName','Enabeld'); exception when dup_val_on_index THEN UPDATE TESTAAD SET Waarde_CD_ROM_BOOT = 'Enabeld' WHERE Waarde_pcName = '$Waarde_pcName'; END;"
            $cmd = $con.CreateCommand()
            $cmd.CommandText = $qu
            $cmd.ExecuteNonQuery() |out-null
        }

Upvotes: 1

Related Questions