我想使用PowerShell读出我的启动顺序设置。我可以使用以下脚本获取:
$bios = Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class hp_biosSetting
($bios | Where-Object {$_.Name -eq 'Boot Order'}).Value.Split(',')
然而,我得到的输出不正确。我只想要值,但我得到值和设置的名称。例如:
USB Floppy Disabled
我唯一能找到的就是用,
拆分它,但我只希望将值作为输出。
答案 0 :(得分:0)
正确答案。
$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
}