我已经实现了一个 powershell 脚本,该脚本在 MDT 安装 windows 10 或 windows 7 期间设置了 bios 参数,我将它集成到我的服务器 MDT 中,就像 windows 任务序列中的“运行 Powershell 脚本”一样,但如果我不工作在winpe中测试我的脚本运行良好,但安装操作系统后,如果我检查bios,什么都没有发生。我通过os任务序列集成了我的脚本,在任务序列中右键单击,点击add=>general=>run powershell,然后我把路径和我的脚本的名称像%SCRIPTROOT%myscript.ps1。对于执行策略,我将其称为“运行命令行”:powershell.exe -command“Set-ExecutionPolicy Unrestrictebd”。
这是我的 Windows 10 脚本,可能是我错过了什么
$computerManufacturer = (Get-WmiObject win32_computersystem).manufacturer
if($biosManufacturer -ceq "Dell Inc." -or $computerManufacturer -ceq "Dell Inc." ){
#Activation du mode UEFI
$bios= Get-WmiObject DCIM_BIOSService -namespace root\dcim\sysman
$bios.SetBIOSAttributes($null,$null,"Boot Mode","2")
#Desactivation du legacy
$bios.SetBIOSAttributes($null,$null,"Enable Legacy Option ROMs","1")
#Activation du secure Boot
$bios.SetBIOSAttributes($null,$null,"Secure Boot","2")
}
Windows 7的第二个是
$biosManufacturer = (Get-WmiObject win32_Bios).manufacturer
$computerManufacturer = (Get-WmiObject win32_computersystem).manufacturer
if($biosManufacturer -ceq "Dell Inc." -or $computerManufacturer -ceq "Dell Inc." ){ echo $computerManufacturer
#Desactivation du mode UEFI au detriment de Legacy
$bios=Get-WmiObject -class DCIM_BIOSService -namespace root\dcim\sysman
$bios.SetBIOSAttributes($null,$null,"Enable Legacy Option ROMs","2")
$bios.SetBIOSAttributes($null,$null,"Boot Mode","1")
#Desctivation du secure Boot
#$bios.(Get-WmiObject DCIM_BIOSService -namespace root\dcim\sysman ).SetBIOSAttributes($null,$null,"Secure Boot","1")
}
elseif($computerManufacturer -ceq "HP" -or $computerManufacturer -ceq "Hewlett-Packard" ){
#Activation du mode UEFI du mode UEFI
$bios=Get-WmiObject -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
$bios.SetBIOSSetting("Configure Legacy Support and Secure Boot", "Legacy Support Enable and Secure Boot Disable","")
$bios.SetBIOSSetting("UEFI Boot Options", "Disable","")
$bios.SetBIOSSetting("Legacy Boot Options", "Enable","")
}
如果有人有任何想法,我会欣赏它!