SCCM CB CCMSetup Exit Code Collector PowerShell Script

1
CCMSetup Exit Code Collector

SCCM is client server software and we need to update SCCM client software updated with all SCCM CB upgrades. So, I hope this script will help to ease some of the burden in troubleshooting SCCM client related issues. There are many methods to install SCCM client. In fact we are aware which method to choose out the best approach in our working environment in domain joined and work-group machines. From workstation perspective we will confirm the successful installation based on the exit code 0 from CCMSetup log.

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 install 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 are failing with this particular error let me take exit code 7 which stands for reboot pending for any of its prerequisites
Thus categorization of machines and their error are very much 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 to save loads of time for new implementation scenarios. As well as CCMSetup Exit Code Collector PowerShell Script will help us in SCCM CB upgrade scenarios as well.

How to Use – CCMSetup Exit Code Collector

The exit code description and solution has 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

Script will fail if it is unable to connect the remote machine. Using the script logic (function) entire content of ccmsetup will be captured and stored in $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.csv

Download CCMSetup Exit Code Collector Script

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

Download the FULL CCMSetup Exit Code Collector PowerShell Script

Results of CCMSetup Exit Code Collector

CCMSetup Exit Code Collector

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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