Skip to content
SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr

SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr

Written By Regin
Last Updated August 12, 2024
Posted In SCCM
SHARE

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 ease some of the burdens of troubleshooting SCCM client-related issues.

There are many methods for installing SCCM clients. We know which approach is best for our working environment in domain-joined and workgroup machines.

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

While troubleshooting Client installs, we will connect the c$ of a machine and look for the exit code, such as “ 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.

Patch My PC

Why Do You Need CCMSetup Exit Code Collector PowerShell Script?

We must 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 installation. This PowerShell script will check the ccmsetup.log of client machines and its exit code with its description and solution to an Excel file. 

The CCMSetup Exit Code Collector script helps SCCM admins save time when implementing new scenarios. The CCMSetup Exit Code Collector PowerShell Script will also help us in SCCM CB upgrade scenarios.

SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr - Fig.1
SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr – Fig.1

How to Use – CCMSetup Exit Code Collector

The exit code description and solution are provided in the SCCMData.xml file hosted in the TechNet gallery. If the XML is unavailable in the current folder, the script will download it from Technet.

$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 cannot connect to the remote machine. Using the script logic (function), the 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 Split and Formatted like the below
LogText: CcmSetup is exiting with return code 0
Type :
Component: ccmsetup
DateTime : 3/6/2018 8:20:17 PM
Thread: 3384
SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr – Table 1

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 is 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

You can download the full script and the XML from the GitHub repository. You might need to make some changes to the script. I suggest providing feedback, and depending upon that, I will upload this to the GitHub repository so that the SCCM community can help develop the script further.

Download the FULL CCMSetup Exit Code Collector PowerShell Script

Results of CCMSetup Exit Code Collector

Let’s discuss the Results of CCMSetup Exit Code Collector. The screenshot below helps you show more details.

SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr - Fig.2
SCCM CB CCMSetup Exit Code Collector PowerShell Script ConfigMgr – Fig.2

We are on WhatsApp now. To get the latest step-by-step guides, news, and updates, Join our Channel. Click here. HTMD WhatsApp.

Author

Regin is an experienced Windows SCCM and PowerShell Admin with 6.5 years of experience. He is an expert in SCCM and PowerShell. He already published several PowerShell scripts for Tech Community.

Written by

Regin is experienced Windows SCCM and PowerShell Admin with 6.5 years of experience. He is expert in SCCM and PowerShell. He already published several PowerShell scripts for Tech Community.

Discussion · 1 comment

Join the discussion

Your email address will not be published. Required fields are marked *

Related guides

Intune

Windows 11 KB5101650 KB5099414 July 2026 Patch and 3 Zero Day Vulnerabilities and 570 Flaws

Key Takeaways Windows 11 KB5101650 KB5099414 July 2026 Patch and 3 Zero Day Vulnerabilities and 570 Flaws! In the July 2026 Patch, Microsoft introduced new features designed to improve the overall Windows experience. The update adds enhancements to Windows Update for more flexible update management and introduces Point-in-Time Restore, providing an additional recovery option for […]

AC Anoop C Nair 9 min read
Intune

2026 June KB5094126 KB5093998 Windows 11 Patch | 3 Zero Day Vulnerabilities and 200 Flaws

Key Takeaways 2026 June KB5094126 KB5093998 Windows 11 Patch | 3 Zero Day Vulnerabilities and 200 Flaws! The June 2026 Windows 11 Patch Tuesday update brings several improvements to File Explorer. It adds support for additional archive formats, including UU, CPIO, XAR, and NuGet Packages (NUPKG). The update also preserves View and Sort preferences in […]

AC Anoop C Nair 10 min read
Intune

2026 May KB5089549 KB5087420 Windows 11 Patch | 0 Zero Day Vulnerabilities and 120 Flaws

Key Takeaways The Windows 11 May 2026 Patch KB5089549 KB5087420 Update brings important security fixes, performance improvements, and reliability enhancements across the operating system. The update introduces new features such as Xbox Mode for gaming, File Explorer improvements, enhanced input and sharing experiences, better taskbar and Windows Hello reliability, and additional enterprise management capabilities for […]

AC Anoop C Nair 8 min read
SCCM

ConfigMgr 2603 Introduces New Early Update Enrollment Process

Key Takeaways In this post we are discussing the ConfigMgr 2603 Introduces New Early Update Enrollment Process. Microsoft has officially released Configuration Manager version 2603 to the Early Update Ring, giving organizations an opportunity to test upcoming improvements before the global production rollout. The release is targeted at enterprises running ConfigMgr version 2409 or later […]

AC Anoop C Nair 3 min read