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

Adaptiva

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.

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.