Following the article I wrote on capturing BIOS information in your environment which can be found here, I packaged BIOS packages via the traditional route in SCCM for a customer.

One of the findings that the customer was experiencing is that users would often forget a BIOS upgrade was about to be performed and would fail since they would not connect a power supply or their battery would not be above a certain percentage (With Dell it is 11%). That said, even if they would have a power supply connected, they would often forget that the install was in progress and would unplug the power and would walk away which would eventually fail the BIOS install. Even though BIOS install usually contains a check within the OS and another when out of it, I decided to make it easier on the user by educating them by using a GUI. Who would blame them if they were not really reading the preconditions defined in Software Center and just clicking through just like every other application.

With this concern, I decided to create a UI which would display the requirements in a GUI but also bold enough to not loose their attention. Trust me, educating users clearly can save IT administrators a lot of work. Secondly, I wanted to make sure that the UI could not be closed by using the regular ‘close button’ as often users would ignore that window and close it saying they were working on something else and did not remember to run it again. At this point I know what your thinking – “Why not push via enforcement?”. The BIOS install unlike other application comes with a caveat that a reboot is mandatory and not letting users save their work is not a choice in our case. With this solution, I have tried to achieve persistence of the installation yet notifying the users gently that they have not met the pre-conditions of a mandatory upgrade. Keep in mind this is a one off stay current exercise.

The image below is customization based on individual needs but its a screenshot of what I created in Photoshop.



# Powershell script to notify users via UI regarding pre-requisite conditions for BIOS upgrade to be successful. 
# Script checks for AC power connection and battery greater than 11% based on the requirements by Dell.

# Author - Vikram Bedi 

#Powershell v2.0 
#v1.0 Initial Script

#local client intiallization
Param($computer = "localhost")

#Capture Battery information via Win32_Battery for power source, battery state and estimated battery remaining.
Function Measure-Battery {
$computername = $env:computername)
1 = "Discharging"
2 = "On A/C"
3 = "Fully Charged"
4 = "Low"
5 = "Critical"
6 = "Charging"
7 = "Charging High"
8 = "Charging Low"
9 = "Charging Critical"
10 = "Undefined"
11 = "Partially Charged"
1 = "Other"
2 = "Unknown"
3 = "Running or Full Power"
4 = "Warning"
5 = "In Test"
6 = "Not Applicable"
7 = "Power Off"
8 = "Off Line"
9 = "Off Duty"
10 = "Degraded"
11 = "Not Installed"
12 = "Install Error"
13 = "Power Save - Unknown"
14 = "Power Save - Low Power Mode"
15 = "Power Save - Standby"
16 = "Power Cycle"
17 = "Power Save - Warning"

#Get the battery data from the Win32_Battery wmi class
Get-CimInstance -ClassName Win32_battery -ComputerName $computername |
Select PSComputername,
@{Name = "Runtime";Expression={New-TimeSpan -minutes $_.EstimatedRunTime}},
@{Name = "PctRemaining";Expression={$_.EstimatedChargeRemaining}},
@{Name = "MyAvailability";Expression={$availHash.Item($($_.Availability -as [int]))}},
@{Name = "BatteryStatus";Expression={ $statushash.Item($($_.batterystatus -as [int]))}}
} #end function
Set-Alias -Name $computer -Value Measure-Battery

#Intialize form to display screen and button with screen size
$objForm = New-Object System.Windows.Forms.Form 
$objForm.Size = New-Object System.Drawing.Size(600,600) 
$objForm.StartPosition = "CenterScreen"

#Intialize variable with the image file
$file = (get-item 'BIOS Installation Toolkit.jpg')
$img = [System.Drawing.Image]::Fromfile($file);

#Create picture box based on the height and width
$pictureBox = New-object System.Windows.Forms.PictureBox
$pictureBox.Width = $img.Size.Width;
$pictureBox.Height = $img.Size.Height;

#Label box but not in use
#$textLabel1 = New-Object System.Windows.Forms.Label
#$textLabel1.Location = New-Object System.Drawing.Size(60,800)
#$textLabel1.Size = New-Object System.Drawing.Size(217,23) 
#$textLabel1.Text = ""

# Init ProgressBar but not in use
#$pbrTest = New-Object System.Windows.Forms.ProgressBar
#$pbrTest.Maximum = 0 #1900
#$pbrTest.Minimum = 0
#$pbrTest.Location = new-object System.Drawing.Size(17,240)
#$pbrTest.size = new-object System.Drawing.Size(300,25)
#$i = 0

# Button
$btnConfirm = new-object System.Windows.Forms.Button
$btnConfirm.Location = new-object System.Drawing.Size(250,525)
$btnConfirm.Size = new-object System.Drawing.Size(100,30)
$btnConfirm.Text = "Begin Installation"

$wshell = New-Object -ComObject Wscript.Shell

# Button Click Event which check the requirements are met and display popup menus if 
{ $Battery = Measure-Battery -computername $computer
 if ($Battery.BatteryStatus -eq 'On A/C')
 Write-Host "Power Supply Connected" 
 if ($Battery.PctRemaining -gt 11)
 Write-Host "Battery sufficent"
 #Logic included to only close the UI screen through the 'Begin Installation' button if conditions are met. The close window or 'x' button will not close the UI.
 $objForm.Add_FormClosing( { $_.Cancel = $false; } ) 
 Write-Host "Battery not sufficent"
 $wshell.Popup("Battery not suffient. Cuurent battery is '$Battery.PctRemaining'% and needs to be greater than 11%",0,"BIOS Installation toolkit")
 Write-Host "Power Supply not Connected"
 $wshell.Popup("Power supply not connected. Please connect AC and try again",0,"BIOS Installation toolkit") 
#Progress bar timer but not in use.
# While ($i -le 1900) 
# {
# $pbrTest.Value = $i
# Start-Sleep -m 1
# $i 
# $i += 1
# }

#Execution of form with image and button. 
$pictureBox.Image = $img;
$objForm.Add_Shown( { $objForm.Activate() } )
#Logic included to not close the UI screen through the close window or 'x' button
$objForm.Add_FormClosing( { $_.Cancel = $true; } )