I promised last week I would write a blog post on how I use OSDbackground in case of a Task sequence failure, so here it is. OSDbackground gives us the possibility to show an error in case a Task Sequence fails and when doing so it also provides us with the option to read all TS variables and open a command Prompt or CMtrace without having F8 Support enabled.
Well, to handle errors in a Task Sequence I use a couple of small scripts that I will describe here and that can be downloaded further down in the blog post. Basically, the functionality is the same as in an MDT integrated Task Sequence.
We start by using a group called “Execute Task Sequence” with the “continue on” error option selected.
Then we run our whole Task Sequence within that group, in that way we can catch any error in a group later in the Task Sequence.
I also set the variable shown above “SMSTSErrorDialogTimeOut” to “28800” which equals 8 hours. If the task sequence fails, the countdown timer will count down from 8 hours before restarting.
In the end of the Task Sequence we have two groups, “OSD Completion” and “OSD Error”.
The OSD Completion group is run as the name indicates when the Task Sequence is successful, using the Task Sequence variable “_SMSTSLastActionSucceeded” = “True”. We remove the computer from the OSD Collection using the Onevinn WebService in this group as well.
I also added a little step to stop the OSDBackground process, if we don’t restart the computer after we started OSDBackground the last time it will still show as desktop background when the user logs on.
The Powershell script used looks like this.
Stop-Process -Name “OSDBackground” -Force -ErrorAction SilentlyContinue
What if the Task Sequence fails?
In the OSD Error group we have a couple of interesting steps as well. The OSD Error code has the following condition. Using the same Task Sequence variable as before when there is an error in the Task Sequence, “_SMSTSLastActionSucceeded” = “False”.
The next step saves the error code from the Task Seqeunce step that actually failed in a Task Sequence variable called “ErrorReturnCode”. We use that later to actually fail the Task Sequence using a script but with the original error code.
The next step uses OSDBackground to change the Background image and enable us to open a password protected debug mode with ,command prompt support without having F8 enabled.
The next three steps are from the sample scripts in the Onevinn OSD WebService, and the first one sets a couple of variables we need to be able to remove it from the Collection used to target the OS deployment.
The next step remove the computer from the OSD Collection.
We can then disable the computer account using the Web Service in the domain to make sure no one uses a computer with a failed OS deployment potentially missing anti-virus and much more.
Then we use a small script that will fail the Task Sequence with the original error code that we saved in the variable before.
The script used looks like this:
$tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
exit $tsenv.Value(“ErrorReturnCode”)
The result is a Task Sequence that will end up with this dialog when it fails.
Now we can right-click in the upper left corner and supply the configured password to open the debug options in OSDBackground and troubleshoot our Task Sequence error without having F8 enabled in our boot image.
OSDBackground was updated on Technet yesterday as well, so if you don’t have CMtrace in your image, you can just copy Cmtrace.exe to the OSDBackground package and it will copy CMtrace to the local drive so it can be used to read the log files. A great addition by Johan!
The two scripts used can be downloaded here and I would add them to the OSDBackground package so we can run them from the same package in our Task Sequence.
Thanks Johan Schrewelius for creating OSDBackground!!
About OSD Completion group and conditions. In your screenshot there is “if all the conditions are true” but should it be just Task Sequence Variable _SMSTSLastActionSucceeded = TRUE without the IF statement like in the OSD Error group
Hi,
I have implemented the osdbackground on my win10 ts, but I have two problems…
If i add the TrustLocalIntraNet.ps1 after a reboot the preferences I had in my gpo don’t work because the ps1 cripts adds some values to the registry key….so I remove the background after the firs nedded rebboot…Done this it seems that the error page doesn’t appear anymore after an error but only the error task is shown but i can do nothing to understand the error…..Any idea?
Thanks
Hi
I m trying to capture the error and write it to a registry. While everything works as expected, I m unable to set the task sequence error.. The ‘set error’ step succeeds without settled the task sequence failure.
Your help on this will be greatful!
Thanks
Can this be used during Win10 Upgrade TS?
Tried to use it and it doesn’t produce anything. Maybe I’m missing something?
Basically I have a simple TS for Windows 10 Upgrade with few steps including OSDBackground. Before I start the TS and test it directly from PowerShell it works just fine. As soon as I start the TS it won’t work, even running it directly from PS. I’m seeing OSDBackground process is running but no background displayed.
Any help will be really appreciated.
Hi,.
You should look at UPGBackground instead which is in the Windows 10 upgrade tools
https://gallery.technet.microsoft.com/Windows-10-Upgrade-Tools-431094ca
/Jörgen
Hi Jörgen,
we want to use TSBackground for our TS, but we have one show stopper. In the “prepare Computer System” step we disable the UEFI Network Stack of our Dell Latitude devices with command line “cmd /c cctk –uefinwstack=disable –ValSetupPwd=********”. When the command run TSBackground freeze instant and the osd stands still, connection to TSBackground Remote Control lost too. Every other command cctk command is running well, only uefinwstack isn’t working, but we need it to avoid a boot loop.
Kind regards