PoshCode Archive  Artifact [f52938cb8b]

Artifact f52938cb8b6d20c2bdebab61065c97e48fe6581369a3b64a409c650b486798dc:

  • File Check-latest-BIOS-Rev.ps1 — part of check-in [554a091fa1] at 2018-06-10 13:14:13 on branch trunk — 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) (user: Jeff Patton size: 2687)

# encoding: ascii
# api: powershell
# title: Check latest BIOS Rev
# description: 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)
# version: 0.1
# type: class
# author: Jeff Patton
# license: CC0
# x-poshcode-id: 2678
# x-derived-from-id: 2679
# x-archived: 2016-04-26T22:26:24
# x-published: 2012-05-17T09:03:00
#
# Added the download stuff.
#
$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 = "<span id=`"Version`" class=`"para`">"

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
    
    $BIOSDownloadURL = $DellPage.Substring($DellPage.IndexOf("http://ftp"),(($DellPage.Substring($DellPage.IndexOf("'http://ftp"),100)).indexof(".EXE'"))+3)
    $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)"
}