SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr

SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr. SCCM is client-server software, and we need to update SCCM client software with all SCCM CB upgrades. So, I hope this script will help to ease some of the burdens in troubleshooting SCCM client-related issues.

There are many methods to install SCCM clients. We know which way to choose the best approach in our working environment in domain-joined and work-group machines.

We will confirm the successful installation based on exit code 0 from the CCMSetup log from a workstation perspective.

Patch My PC

Content

  • Why do you need CCMSetup Exit Code Collector PowerShell Script?
  • How to Use – CCMSetup Exit Code Collector
  • Error Handling – CCMSetup Exit Code Collector Script
  • Download CCMSetup Exit Code Collector Script
  • Results of CCMSetup Exit Code Collector

Why do you need CCMSetup Exit Code Collector PowerShell Script?

While troubleshooting Client installs, we will connect the c$ of a machine and look for the exit code like “ CcmSetup is exiting with return code 0”.However, there will be cases where “CcmSetup is exiting with return code 7” or “CcmSetup is exiting with return code 1603,” and so on.

We need to understand how many of my clients fail with this particular error. Let me take exit code 7, which stands for reboot pending for any of its prerequisites.


Thus, machine categorization and error are needed before acting upon these issues rather than re-initiating the client install.

This PowerShell script will check the ccmsetup.log of client machines and its exit code with its description and solution to an excel file. 

CCMSetup Exit Code Collector script helps SCCM admins save time for new implementation scenarios. As well as CCMSetup Exit Code Collector PowerShell Script will help us in SCCM CB upgrade scenarios.

How to Use – CCMSetup Exit Code Collector

The exit code description and solution have been provided in the SCCMData.xml file. This XML is hosted in the TechNet gallery. Script will download the XML from Technet if it is not available in the current folder.

$url =”https://gallery.technet.microsoft.com/Sccm-Client-Install-Exit-91da7a87/file/192751/1/SCCMClientExitCode.xml” $filename=”SCCMData.xml” $webclient = New-Object System.Net.WebClient $webclient.DownloadFile($url,$xmlFile) Connecting the CCMSetup.log file of remote computer $PingRequest = Test-Connection -ComputerName $Comp -Count 1 -Quiet if ( $pingRequest -eq $true){ $ccmsetup_log=”\\$comp\c$\Windows\ccmsetup\Logs\ccmsetup.log”

Error Handling – CCMSetup Exit Code Collector Script

The script will fail if it is unable to connect to the remote machine. Using the script logic (function) entire content of ccmsetup will be captured and stored in the $string variable.

$string=Read-CMLogfile -path $ccmsetup_log <time=”20:20:17.515-330″ date=”03-06-2018″ component=”ccmsetup”

This data will be spilt and formatted like below

  • LogText : CcmSetup is exiting with return code 0
  • Type :
  • Component : ccmsetup
  • DateTime : 3/6/2018 8:20:17 PM
  • Thread : 3384

Now the $string.LogText will have “CcmSetup is exiting with return code 0”. The Last part of the string 0 gets split and its respective value of description and solution from XML will be stored in variables.

  • $ccmsetup_val[-1].split()[-1]
  • Output will be saved in output.csv
  • $exitcode=$ccmsetup_val[-1].split()[-1]
  • $XmlDoc =[xml](Get-Content -Path $xmlFile)
  • $value1= $XmlDoc.sccmdata.exit | Where-Object { $_.id -eq $exitcode }
  • New-Object -TypeName PSObject -Property @{
  • ComputerName=$comp
  • EXITCode= $value1.id
  • Description = $value1.Description
  • Solution = $value1.Solution
  • } | Select ComputerName,EXITCode, Description, Solution | Export-Csv -path $currentpath\output.csva

Download CCMSetup Exit Code Collector Script

Download the full script from the TechNet gallery. Script will download the XML from TechNet if it is not available in the current folder. I would suggest providing the feedback, and depending upon that, I will upload this to the GitHub repository. So that SCCM community can help to develop the script further.

Download the FULL CCMSetup Exit Code Collector PowerShell Script

Results of CCMSetup Exit Code Collector

CCMSetup Exit Code Collector
SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr 1

1 thought on “SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.