Hi All,
I put together this simple PS script that will generate a message box with a friendly message that your TS has failed. It will then auto launch your SMSTS.log file with CMTrace and add a Task Sequence variable of “TSFailed” which you can leverage as a step in your Task Sequence if you choose to do so. I have selfish reasons for launching the log files automatically after “Ok” is pressed, i want my techs to learn some basic TS errors so they can come back to me with more information than.. “it broke”…
Hope you can find it useful 🙂
Tip: Place this in your Try/Catch steps in your TS where _SMSTSLastActionSucceeded (False)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Load SCCM TS Environment, Hide TS Progress to see error window. | |
$TS = New-Object -ComObject "Microsoft.SMS.TSEnvironment" | |
$T1 = New-Object -ComObject "Microsoft.SMS.TsProgressUI" | |
$T1.CloseProgressDialog() | |
#Stop CM Trace Prompting for Default Viewer. | |
reg add HKCU\SOFTWARE\Microsoft\Trace32 /V "Register File Types" /d 0 /f | |
#Load Form Code | |
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null | |
#$SMSTSPackageName = $TS.Value("_SMSTSPackageName") | |
#$OSDComputerName = $TS.Value("OSDComputerName") | |
#$SMSTSLogPath = $TS.Value("_SMSTSLogPath")+"\smsts.log" | |
#Generate Form Code | |
[System.Windows.Forms.MessageBox]::Show("TS '$SMSTSPackageName' has failed on '$OSDComputerName'! `nPlease click OK to review logs and report the failure to your SCCM Admin before trying again." , "TS Failure") | |
if ($OKButton -eq "OK" ) | |
{ | |
cmtrace.exe "$SMSTSLogPath" | |
$TS.Value("TSFailed") = "true" | |
} | |
else | |
{ | |
cmtrace.exe "$SMSTSLogPath" | |
$TS.Value("TSFailed") = "true" | |
} |
Another cool method to notify you of failures is Rich Mawdsley’s method here: https://richmawdsleyblog.wordpress.com/2017/02/10/guide-making-failed-osd-obvious/