Hi,
Thank you very much for the reply.
MDT and BIOS Upgrade.
https://learn.microsoft.com/en-us/answers/questions/709413/mdt-and-bios-upgrade.html
I've read the above related thread and gotten some information. I think the logic is as below:
get the current version and compare with the .txt file
if (the current version is not the newest )
{
execute the upgrade BIOS prograss, set NeedReboot to Yes, and the reboot is suppressed
}
reboot if NeedReboot is set to Yes
For debugging, we can manually execute the following example cmdlets to simulate the logic. Or, the script you've provided (bios-check.ps1) will log information to BIOS_Update.log, could you share this log for further analysis?
$CompBiosVersion = (Get-WmiObject WIN32_BIOS).SMBIOSBIOSVersion
$CurrentBiosVersion = Get-Content "\\10.1.1.2\d\alex\bios.txt"
$CompBiosVersion
$CurrentBiosVersion
if ($CompBiosVersion.replace(' ' , '') -eq $CurrentBiosVersion.replace(' ' , ''))
{
write-host "BIOS is up to date."
}
example output screenshot (even though there is an extra space character, the versions match)
the script you shared before:
# Load MDT Task Sequence Environment and Logs
$TSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$logPath = $tsenv.Value("LogPath")
$logFile = "$logPath\BIOS_Update.log"
# Start the logging
Write-Output "Logging to $logFile." > $logFile
# Collect data
Write-Output "Collecting Data" >> $logFile
$ScriptRoot = (Get-location).Path
$Model = $TSenv.Value("Model")
$CompBiosVersion = (Get-WmiObject WIN32_BIOS).SMBIOSBIOSVersion
$CurrentBiosVersion = Get-Content "$ScriptRoot\$Model\BIOS.txt"
$Installer = "UpgradeBIOS.cmd"
try {
Test-Path $CurrentBiosVersion -ErrorAction Stop
}
catch {
Write-Output "BIOS.txt does not exist!" >> $logFile
}
Write-Output "Copying $ScriptRoot\$Model to C:\Temp\$Model" >> $logFile
Copy-Item "$ScriptRoot\$Model" "C:\Temp\$Model" -Force -Recurse
# Checking for BIOS update
if($CompBiosVersion.replace(' ' , '') -eq $CurrentBiosVersion.replace(' ' , '')) {
Write-Output "BIOS is up to date." >> $logFile
Exit
}
else {
Write-Output "Updating BIOS $CompBiosVersion to $CurrentBiosVersion." >> $logFile
Start-Process "cmd.exe" "/c C:\Temp\$Model\$Installer" -Wait
$tsenv.Value("NeedReboot") = "YES"
Write-Output "Update has been completed successfully." >> $logFile
Exit
}
Alex
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.