06 February 2017

Automated Dell Command Update

Posted By: Mick Pletcher - 12:23 PM

Share

& Comment
















While working on implementing the new Windows 10 build, I decided to update the Dell Command | Update process. The old script was still looking at the old DCSU and had many inefficiencies that needed to be updated. I also wanted to add new features to the script for logging purposes. With using SAPIEN's PowerShell Studio, the process to update this script was a breeze.

The new script is written so that it can be executed from a command line, build, or a deployment. This now includes the option to write a log file to a specified location by %model%\%ComputerName%. It will delete the old computer name directory and create a new if it already exists. The logs give you the ability to keep track of drivers that may not be applying correctly and you need to inject into SCCM.

Below is how I configured the script in SCCM. The portions I blackened out are the location of the script. It will likely need to be executed as a domain admin account so that it has access to the internet, otherwise you could use the Run PowerShell Script Type.



You can download the script from here.


 <#  
      .SYNOPSIS  
           Update Dell Drivers  
        
      .DESCRIPTION  
           Update Dell drivers using the Dell Command Update.  
        
      .PARAMETER Logging  
           Specifies if logging is to take place  
        
      .PARAMETER LogLocation  
           Location where to write the driver logs  
        
      .NOTES  
           ===========================================================================  
           Created with:     SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.135  
           Created on:       2/3/2017 2:21 PM  
           Created by:       Mick Pletcher  
           Organization:  
           Filename:         DellDriverUpdate.ps1  
           ===========================================================================  
 #>  
 [CmdletBinding()]  
 param  
 (  
      [switch]$Logging,  
      [string]$LogLocation  
 )  
 function Get-Architecture {  
 <#  
      .SYNOPSIS  
           Get-Architecture  
        
      .DESCRIPTION  
           Returns whether the system architecture is 32-bit or 64-bit  
        
      .EXAMPLE  
           Get-Architecture  
        
      .NOTES  
           Additional information about the function.  
 #>  
        
      [CmdletBinding()][OutputType([string])]  
      param ()  
        
      $OSArchitecture = (Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture).OSArchitecture  
      Return $OSArchitecture  
      #Returns 32-bit or 64-bit  
 }  
   
 function Get-DellCommandUpdateLocation {  
 <#  
      .SYNOPSIS  
           Find dcu-cli.exe  
        
      .DESCRIPTION  
           Locate dcu-cli.exe as it may reside in %PROGRAMFILES% or %PROGRAMFILES(X86)%  
        
 #>  
        
      [CmdletBinding()][OutputType([string])]  
      param ()  
        
      $Architecture = Get-Architecture  
      If ($Architecture -eq "32-bit") {  
           $File = Get-ChildItem -Path $env:ProgramFiles -Filter "dcu-cli.exe" -ErrorAction SilentlyContinue -Recurse  
      } else {  
           $File = Get-ChildItem -Path ${env:ProgramFiles(x86)} -Filter "dcu-cli.exe" -ErrorAction SilentlyContinue -Recurse  
      }  
      Return $File.FullName  
 }  
   
 function Invoke-DriverUpdate {  
 <#  
      .SYNOPSIS  
           Execute Dell Command Update  
        
      .DESCRIPTION  
           This will initiate the Dell Command Update using the dcu-cli.exe  
        
      .PARAMETER Executable  
           dcu-cli.exe  
        
      .NOTES  
           Additional information about the function.  
 #>  
        
      [CmdletBinding()]  
      param  
      (  
           [ValidateNotNullOrEmpty()]$Executable  
      )  
        
      If ($Logging.IsPresent) {  
           $Model = (Get-WmiObject -Class Win32_ComputerSystem).Model  
           If ($LogLocation[$LogLocation.Length - 1] -ne "\") {  
                $Location = $LogLocation + "\" + $Model  
           } else {  
                $Location = $LogLocation + $Model  
           }  
           If ((Test-Path $LogLocation) -eq $false) {  
                New-Item -Path $LogLocation -ItemType Directory -Force | Out-Null  
           }  
           If ((Test-Path $Location) -eq $false) {  
                New-Item -Path $Location -ItemType Directory -Force | Out-Null  
           }  
           $Location += "\" + $env:COMPUTERNAME  
           If ((Test-Path $Location) -eq $true) {  
                Remove-Item -Path $Location -Recurse -Force  
           }  
           $Arguments = "/log" + [char]32 + [char]34 + $Location + [char]34  
      } else {  
           $Arguments = [char]32  
      }  
      Start-Process -FilePath $Executable -ArgumentList $Arguments -Wait -Passthru | Out-Null  
 }  
   
   
 Clear-Host  
 #Find dcu-cli.exe  
 $EXE = Get-DellCommandUpdateLocation  
 #Install Dell drivers  
 Invoke-DriverUpdate -Executable $EXE  
   

About Mick Pletcher

My blog is here to help solve issues I have encountered and solved, publish scripts I have written, and educate others in understanding areas that are not well covered

1 comments:

  1. Thank You Mike for the script, It works like a charm.
    Is it possible to exclude few updates(e.g. BIOS, Touchpad) from the list?

    ReplyDelete

Copyright © 2013 Mick's IT Blogs™ is a registered trademark.