11 September 2019

Zero Touch Dell Command Update for SCCM and MDT

I have used the Dell Command | Update in the build for quite some time for managing the drivers on systems because it makes it a hand-off approach with little setup and reliable updates direct from Dell. The one thing I have wanted to be able to rerun this task several times without having to have duplicate tasks in the task sequence. Sometimes there are multiple reboots required because not all drivers can be installed at the same time.

I finally discovered how ZTIWindowsUpdate.wsf reboots and reruns itself without corrupting the task sequence, and I have applied the same code to this script. 

This script will run the dcu-cli.exe to both install updates and generate inventory.xml and activitylog.xml files. The script then reads the activitylog.xml file to see if any drivers were installed. If not, the script ends. If there were updates installed, the script creates a rebootcount.log file if it does not exist, that contains the number of reboots that have been performed. It will increment that number inside the file each time the system is rebooted, and the script is rerun. This had to be included because a few updates Dell deploys do not register with the Dell Command | Update and reinstall every time it is run. Because of that, I limited the script to run 5 times like the ZTIWindowsUdpates.wsf does. I wrote in another blog entry why a task sequence variable cannot be used here to store the reboot count. 

Once the script either has no more updates to install or has run 5 times, it will remove both XML files and end so that SCCM/MDT can continue to the next task. 

The script can be downloaded from my GitHub site


 <#  
      .SYNOPSIS  
           Dell Driver Update  
        
      .DESCRIPTION  
           This script executes the Dell Command | Update and reboots MDT or SCCM up to five times when new updates are available. The reason for the 5 reboot limit is because some Dell updates have been know to not leave markers and will cause the Dell Command | Update to rerun indefinitely.  
        
      .NOTES  
           ===========================================================================  
           Created with:     SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.142  
           Created on:       7/18/2019 1:57 PM  
           Created by:       Mick Pletcher  
           Filename:         ZTIDellDriverUpdate.ps1  
           ===========================================================================  
 #>  
 [CmdletBinding()]  
 param ()  
   
 #Verify Dell Command | Update exists  
 If ((Test-Path -Path (Get-ChildItem -Path $env:ProgramFiles, ${env:ProgramFiles(x86)} -filter dcu-cli.exe -Recurse -ErrorAction SilentlyContinue).FullName) -eq $true) {  
      #Delete old logs if they exist  
      Remove-Item -Path ($env:windir + '\temp\ActivityLog.xml') -ErrorAction SilentlyContinue -Force  
      Remove-Item -Path ($env:windir + '\temp\inventory.xml') -ErrorAction SilentlyContinue -Force  
      #Update the system with the latest drivers while also writing log files to the %windir%\temp directory  
      $ErrCode = (Start-Process -FilePath ((Get-ChildItem -Path $env:ProgramFiles, ${env:ProgramFiles(x86)} -Filter 'dcu-cli.exe' -Recurse).FullName) -ArgumentList ('/log ' + $env:windir + '\temp') -Wait).ExitCode  
      #Read the ActivityLog.xml file  
      $File = (Get-Content -Path ($env:windir + '\temp\ActivityLog.xml')).Trim()  
      #if no updates were found or updates were applied and no required reboot is necessary, then delete the log files  
      If (('<message>CLI: No application component updates found.</message>' -in $File) -and (('<message>CLI: No available updates can be installed.</message>' -in $File) -or ('<message>CLI: No updates are available.</message>' -in $File)))  
      {  
           Remove-Item -Path ($env:windir + '\temp\ActivityLog.xml') -ErrorAction SilentlyContinue -Force  
           Remove-Item -Path ($env:windir + '\temp\inventory.xml') -ErrorAction SilentlyContinue -Force  
           Remove-Item -Path ($env:TEMP + '\RebootCount.log') -ErrorAction SilentlyContinue -Force  
      }  
      else  
      {  
           #Create the file containing number of times this script has rerun if it does not exist  
           If ((Test-Path ($env:TEMP + '\RebootCount.log')) -eq $false)  
           {  
                New-Item -Path ($env:TEMP + '\RebootCount.log') -ItemType File -Value 0 -Force  
           }  
           #Reboot the machine and rerun the Dell Driver Updates  
           If (([int](Get-Content -Path ($env:TEMP + '\RebootCount.log'))) -lt 5)  
           {  
                #Microsoft SCCM/MDT environmental variables  
                $TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment  
                #Reboot the machine once this task is completed and restart the task sequence  
                $TSEnv.Value('SMSTSRebootRequested') = $true  
                #Rerun the same task  
                $TSEnv.Value('SMSTSRetryRequested') = $true  
                #increment the reboot counter  
                New-Item -Path ($env:TEMP + '\RebootCount.log') -ItemType File -Value ([int](Get-Content -Path ($env:TEMP + '\RebootCount.log')) + 1) -Force  
                #End the update process if run 5 or more times, delete all associated log files, and proceed to the next task  
           }  
           else  
           {  
                Remove-Item -Path ($env:windir + '\temp\ActivityLog.xml') -ErrorAction SilentlyContinue -Force  
                Remove-Item -Path ($env:windir + '\temp\inventory.xml') -ErrorAction SilentlyContinue -Force  
                Remove-Item -Path ($env:TEMP + '\RebootCount.log') -ErrorAction SilentlyContinue -Force  
           }  
      }  
 }  
 else {  
      Write-Output 'Dell Command | Update is not installed'  
      Exit 1  
 }  

7 comments:

  1. Can you tell me what version of DCU you are using? I think there's a cli issue with 3.x at least there was...

    ReplyDelete
    Replies
    1. Current user's guide for 3.0 still indicates "no support for command line interface". https://topics-cdn.dell.com/pdf/command-update-v30_users-guide_en-us.pdf

      Delete
  2. Can this be run in winpe to apply bios/firmware updates prior to partitioning the disk / applying wim?

    ReplyDelete
    Replies
    1. Yes, but it is different requirements. I have another blog posting on how to run dcu-cli in the WinPE environment.

      Delete
  3. This is a great script and is working fine except for when Dell cli tries to update the BIOS.

    I currently have a BIOS password set for all our computers so the update fails each time. Normally if you use the GUI dell command interface it will prompt you for the BIOS password first before running the update.

    Is there a way to add my Dell BIOS password to the script so the update will install successfully?

    ReplyDelete
    Replies
    1. Just use the Dell CCTK or whatever it is now, to blank the BIOS pwd, update the BIOS, then have cctk reset the pwd back post update. We do this during our OSD process.

      Delete