29 January 2016

Update Drivers and BIOS via PowerShell and Dell Command Update

NOTE: I used Sapien's PowerShell Studio to write this script that significantly simplified the process!

During the build process, I execute the Dell Command Update to make sure the latest drivers and BIOS version are installed. I use the script below so that it can disable the BIOS password and execute the dcu-cli.exe in either a 32-bit or 64-bit system. The BIOS password must be disabled if you want the BIOS to be updated. Also, I execute the script in two different task sequences. This allows for the BIOS to be completely updated. There are often interval BIOS updates that have to be installed first before the latest can be installed.

You can download the script from here.


 <#       
      .NOTES  
      ===========================================================================  
       Created with:     SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.99  
       Created on:       1/29/2016 2:59 PM  
       Created by:       Mick Pletcher  
       Organization:         
       Filename:        UpdateAll.ps1  
      ===========================================================================  
      .DESCRIPTION  
           Uses Dell Command | Update to update all drivers and BIOS versions.  
 #>  
   
 Function Set-ConsoleTitle {  
      Param ([String]$Title)  
      $host.ui.RawUI.WindowTitle = $Title  
 }  
   
 Function Get-Architecture {  
      #Declare Local Variables  
      Set-Variable -Name Architecture -Scope Local -Force  
        
      $Architecture = Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture  
      $Architecture = $Global:Architecture.OSArchitecture  
      #Returns 32-bit or 64-bit  
      Return $Architecture  
        
      #Cleanup Local Variables  
      Remove-Variable -Name Architecture -Scope Local -Force  
 }  
   
 Function Install-Updates {  
      Param ([String]$DisplayName,  
           [String]$Executable,  
           [String]$Switches)  
        
      #Declare Local Variables  
      Set-Variable -Name ErrCode -Scope Local -Force  
        
      Write-Host "Install"$DisplayName"....." -NoNewline  
      If ((Test-Path $Executable) -eq $true) {  
           $ErrCode = (Start-Process -FilePath $Executable -ArgumentList $Switches -Wait -Passthru).ExitCode  
      } else {  
           $ErrCode = 1  
      }  
      If (($ErrCode -eq 0) -or ($ErrCode -eq 1) -or ($ErrCode -eq 3010)) {  
           Write-Host "Success" -ForegroundColor Yellow  
      } else {  
           Write-Host "Failed with error code "$ErrCode -ForegroundColor Red  
      }  
        
      #Cleanup Local Variables  
      Remove-Variable -Name ErrCode -Scope Local -Force  
 }  
   
   
 Function CCTKSetting {  
      param ($Name,  
           $Option,  
           $Setting,  
           $Drives,  
           $Architecture)  
        
      #Declare Local Variables  
      Set-Variable -Name Argument -Scope Local -Force  
      Set-Variable -Name ErrCode -Scope Local -Force  
      Set-Variable -Name EXE -Scope Local -Force  
        
      If ($Architecture -eq "32-bit") {  
           $EXE = $Env:PROGRAMFILES + "\Dell\Command Configure\X86\cctk.exe"  
      } else {  
           $EXE = ${env:ProgramFiles(x86)} + "\Dell\Command Configure\X86_64\cctk.exe"  
      }  
      If ($Option -ne "bootorder") {  
           $Argument = "--" + $Option + "=" + $Setting  
      } else {  
           $Argument = "bootorder" + [char]32 + "--" + $Setting + "=" + $Drives  
      }  
      Write-Host $Name"....." -NoNewline  
      If ((Test-Path $EXE) -eq $true) {  
           $ErrCode = (Start-Process -FilePath $EXE -ArgumentList $Argument -Wait -Passthru).ExitCode  
      } else {  
           $ErrCode = 1  
      }  
      If (($ErrCode -eq 0) -or ($ErrCode -eq 240) -or ($ErrCode -eq 241)) {  
           If ($Drives -eq "") {  
                Write-Host $Setting -ForegroundColor Yellow  
           } else {  
                Write-Host $Drives -ForegroundColor Yellow  
           }  
      } elseIf ($ErrCode -eq 119) {  
           Write-Host "Unavailable" -ForegroundColor Green  
      } else {  
           Write-Host "Failed with error code "$ErrCode -ForegroundColor Red  
      }  
        
      #Cleanup Local Variables  
      Remove-Variable -Name Argument -Scope Local -Force  
      Remove-Variable -Name ErrCode -Scope Local -Force  
      Remove-Variable -Name EXE -Scope Local -Force  
 }  
   
 #Declare Local Variables  
 Set-Variable -Name Architecture -Scope Local -Force  
 Set-Variable -Name EXE -Scope Local -Force  
   
 cls  
 Set-ConsoleTitle -Title "Dell Client Update"  
 $Architecture = Get-Architecture  
 CCTKSetting -Name "Disable BIOS Password" -Option "valsetuppwd" -Setting "<BIOS Password> --setuppwd=" -Drives "" -Architecture $Architecture  
 If ($Architecture -eq "32-bit") {  
      $EXE = $Env:PROGRAMFILES + "\Dell\CommandUpdate\dcu-cli.exe"  
 } else {  
      $EXE = ${env:ProgramFiles(x86)} + "\Dell\CommandUpdate\dcu-cli.exe"  
 }  
 Install-Updates -DisplayName "Update All Hardware Components" -Executable $EXE -Switches " "  
   
 #Cleanup Local Variables  
 Remove-Variable -Name Architecture -Scope Local -Force  
 Remove-Variable -Name EXE -Scope Local -Force  
   

5 comments:

  1. Thanks for sharing this! It's good for people to continue to update things regularly. It's good to have resources like this!

    ReplyDelete
  2. Have you tried to incorporate this script into a MDT or SCCM deployment task?

    ReplyDelete
    Replies
    1. Yes. That was what I wrote the script for was to update all drivers and the BIOS during a system build.

      Delete
    2. Got it. I am trying to figure out how to do this, without installing DCU. The idea was to juct put the DCU folder in the deployment share and reference dcu-cli.exe from there. Example: z:\applications\DCU\dcu-cli.exe. Non of our users have local admin rights, and we try to install the least amount of software possible. However I think this such an important step that I would consider installing DCU just to get this functionality to work. I am interested in your thoughts on my no install approach?

      Delete
  3. Thank you for your work and contribution. I've been wanting a way to automate and schedule hundreds of Dell workstations where remotely logging in (in any way) would be far too time-consuming. I was able to create a short script in my RMM (Kaseya) that executes your ps script against hundreds of dell workstations. Much appreciated.

    ReplyDelete