Check DELL computer for latest BIOS Version

This script is pretty simple, it connects to a remote computer and grabs the BIOS class. It then connects to the Dell support page for the remote computer’s ServiceTag. If the computer is a Dell, it grabs the BIOS revision listed on the page. The inspiration came from reading the Scripting Guy blog about comments. (http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/16/add-excellent-comments-to-your-powershell-script.aspx)

$BiosRev = Get-WmiObject –Class Win32_BIOS -ComputerName $ComputerName -Credential $Credentials
# Shortened URL for the Dell Support page, fileid=441102, appears to be the identifier for BIOS downloads
# I tested this on a few different models of Dell workstations.
$DellBIOSPage = “http://support.dell.com/support/downloads/download.aspx?c=us&cs=RC956904&l=en&s=hied&releaseid=R294848&SystemID=PLX_960&servicetag=$($BiosRev.SerialNumber)&fileid=441102”
# This HTML code immediately preceed’s the actual service tag, you can see it when you ‘view source’ on the page
$DellPageVersionString = “
If ($BiosRev.Manufacturer –match “Dell”)
{
$DellPage = (New-Object -TypeName net.webclient).DownloadString($DellBIOSPage)
# Assuming that Dell BIOS rev’s remain 3 characters, I find where my string starts and add the length to it
# and the substring returns the BIOS rev.
$DellCurrentBios = $DellPage.Substring($DellPage.IndexOf($DellPageVersionString)+$DellPageVersionString.Length,3)
If (($BiosRev.SMBIOSBIOSVersion –eq $DellCurrentBios) –eq $false)
{
# Download the latest installer if the Rev’s don’t match
# Assuming Dell continues to use FTP for downloads, find the download URL
# This returns just the URL portion of the HTML code
$BIOSDownloadURL = $DellPage.Substring($DellPage.IndexOf(“http://ftp”),(($DellPage.Substring($DellPage.IndexOf(“‘http://ftp”),100)).indexof(“.EXE”))+3)
# Pull the filename from the end of the path, the 12’s indicate 8+3 that Dell is using
# for filenames, if that changes this should as well.
$BIOSFile = $BIOSDownloadURL.Substring(($BIOSDownloadURL.Length)-12,12)
If ((Test-Path “C:\Dell\”) –eq $false)
{
New-Item -Path “C:\” -Name “Dell” -ItemType Directory
}

If ((Test-Path “C:\Dell\$($ComputerName)”) –eq $false)
{
New-Item -Path “C:\Dell” -Name $ComputerName -ItemType Directory
}
(New-Object -TypeName net.webclient).DownloadFile($BIOSDownloadURL,”C:\Dell\$($ComputerName)\$($BIOSFile)”)
Write-Host “Latest BIOS for $($ComputerName) downloaded to C:\Dell\$($ComputerName)\$($BIOSFile)”
}
}

About the Author

Leave a Reply

You may also like these