Powershell: Pause SCCM Task Sequence with Message Box, Auto launch SMSTS.log

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)


#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"
}

view raw

sccm_messageBox

hosted with ❤ by GitHub

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/
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s