$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment -ErrorAction SilentlyContinue
$tsenv.Value("SMSTS_BiosUpdate") = "True"
#Create Log Path
$LogPath = $tsenv.Value("_SMSTSLogPath")
#Get Bios Password from File
$BiosPassword = Get-Content .\Bios.txt
#Create Model Variable
$ComputerModel = Get-WmiObject -Class Win32_computersystem | Select-Object -ExpandProperty Model
if (test-path ".\$ComputerModel")
{
#Copy Bios Installer to the root of the package - the Flash64W didn't like when I left it in the Computer Model folder, because it has spaces. (Yes, I tried qoutes and stuff)
Copy-Item $ComputerModel\*.exe -Destination $PSScriptRoot
#Get Bios File Name (Uses the Bios EXE file in the same folder)
$BiosFileName = Get-ChildItem $ComputerModel\*.exe -Verbose | Select -ExpandProperty Name
#Get Bios File Name (No Extension, used to create Log File)
$BiosLogFileName = Get-ChildItem $ComputerModel\*.exe -Verbose | Select -ExpandProperty BaseName
$BiosLogFileName = "$BiosLogFileName.log"
#Set Arguments for Bios Update
$BiosArguments = "/s /p=$BiosPassword /l=$LogPath\$BiosLogFileName"
#Run Test Run - For some reason if I don't do this, I get odd error about can't read memory.. bla bla
start-process "$PSScriptRoot\Flash64W.exe" /"p=$BiosPassword /s"
#Update Bios
$Process = start-process "$PSScriptRoot\Flash64W.exe" /b="$PSScriptRoot\$BiosFileName $BiosArguments" -UseNewEnvironment -PassThru -wait
#Creates and Set TS Variable to be used to run additional steps if reboot requried.
if ($process.ExitCode -eq 2)
{$tsenv.Value("SMSTS_BiosUpdateRebootRequired") = "True"}
else
{$tsenv.Value("SMSTS_BiosUpdateRebootRequired") = "False"}
if ($process.ExitCode -eq 10)
{$tsenv.Value("SMSTS_BiosUpdateBatteryCharge") = "True"}
else
{$tsenv.Value("SMSTS_BiosUpdateBatteryCharge") = "False"}
}
3. 创建TaskSequence执行升级脚本
结构如下,先创建一个group并添加condition - select * from Win32_ComputerSystem where Model like '%Latitude%'
为每个型号系列创建一个run command 并按照对应型号创建condition, 如latitude - select * from Win32_ComputerSystem where Model like '%Latitude%'
command line 一栏输入 powershell.exe -NoProfile -ExecutionPolicy ByPass -file .\DellBiosUpgradePackage-2.0.ps1