25 November 2013

Verify applications were installed during build process

Posted By: Mick Pletcher - 9:34 PM

Share

& Comment

As many of you have probably experienced, SCCM and MDT do not always install all of the applications that are in the task sequence list, even if it returned an error code 0. This can be rather annoying, especially when it happens in the build process of the golden image. In order to get around this issue, I wrote the PowerShell script below that will use WMI to verify all of the applications were installed during the task sequence process. All that you should have to do to make custom changes for your environment is to open up the script and add your apps. You will see four examples I put in this script, AppInstalled "Adobe Reader"  being one example. The Adobe Reader in parenthesis can be changed to any app, such as Microsoft Office. You do not need to enter the entire application name, as I have written the function to be able to search for just part of the name. I used the Adobe Reader example because your company may have more than one version of reader and this can search any version being just a portion of the name.

In order to properly implement this, I would suggest putting this as a task sequence and then immediately pausing the build so that you can review the output of this and manually install any applications that may have failed before the golden image is generated. To pause the build for MDT, you can initiate the LTISuspend.wsf as a task sequence. SCCM does not have this wsf file, so you can create a simple, one line VBS file that calls the MSGBOX which will wait for you to click OK on. The VBS can also be used in MDT instead of the LTISuspend.wsf.

You can download this script here.

 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 25 November 2013  
 #  
 #   Program: Check Build  
 #*******************************************************************************  
 Clear-Host  

 #Declare Global Memory  
 $app = ,@()  
 Set-Variable -Name Count -Scope Global -Value 1 -Force  
 Set-Variable -Name OS -Scope Global -Force  
 Set-Variable -Name RelativePath -Scope Global -Force  

 Function RenameWindow ($Title) {  

      #Declare Local Memory  
      Set-Variable -Name a -Scope Local -Force
  
      $a = (Get-Host).UI.RawUI  
      $a.WindowTitle = $Title  

      #Cleanup Local Memory  
      Remove-Variable -Name a -Scope Local -Force
  
 }  

 Function AppInstalled($Description) {
  
      #Declare Local Memory  
      Set-Variable -Name AppName -Scope Local -Force  
      Set-Variable -Name AppLocal -Scope Local -Force  
      Set-Variable -Name Desc -Scope Local -Force  
      Set-Variable -Name Output -Scope Local -Force
  
      $object = New-Object -TypeName PSObject  
      #Change '%application%' to whatever app you are calling  
      $Desc = [char]34+"description like"+[char]32+[char]39+[char]37+$Description+[char]37+[char]39+[char]34  
      $Output = wmic product where $Desc get Description  
      $Output | ForEach-Object {  
           $_ = $_.Trim()  
             if(($_ -ne "Description")-and($_ -ne "")){  
                $AppName = $_  
             }  
      }  
      $AppLocal = New-Object System.Object  
      $AppLocal | Add-Member -type NoteProperty -name Application -value $Description  
      If ($AppName -ne $null) {  
           #$Global:app+=,@($Description,"Installed")  
           $AppLocal | Add-Member -type NoteProperty -name Status -value "Installed"  
      } else {  
           #$Global:app+=,@($Description,"Not Installed")  
           $AppLocal | Add-Member -type NoteProperty -name Status -value "Not Installed"  
      }  
      $Global:app += $AppLocal  
      $AppLocal | Select Application  
      $Global:Count++  

      #Cleanup Local Memory  
      Remove-Variable -Name AppName -Scope Local -Force  
      Remove-Variable -Name AppLocal -Scope Local -Force  
      Remove-Variable -Name Desc -Scope Local -Force  
      Remove-Variable -Name Output -Scope Local -Force
  
 }  

 cls  
 Write-Host "Processing Applications"  
 Write-Host  
 RenameWindow "Check Build Installs"  
 AppInstalled "Dell Client System Update"  
 AppInstalled "Adobe Reader"  
 AppInstalled "Microsoft Lync"  
 cls  
 Write-Host "Installation Report"  
 Write-Host  
 $app | Format-Table
  
 #Cleanup Global Memory  
 $app.Clear()  
 Remove-Variable -Name Count -Scope Global -Force  
 Remove-Variable -Name OS -Scope Global -Force  
 Remove-Variable -Name RelativePath -Scope Global -Force  

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

0 comments:

Post a Comment

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