Menu
CCMEXEC.COM – Enterprise Mobility
  • General
  • Configuration Manager
  • Windows 10
  • Windows 11
  • Intune
  • GitHub
  • About
CCMEXEC.COM – Enterprise Mobility

Error handling in TS without MDT using OSDBackground

Posted on December 15, 2016August 21, 2017 by Jörgen Nilsson

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.

TS error handling

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.

SMSTSErrorDialogTimeOut

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.

OSDCompletionGroup

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

OSDErrorGroup

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.

SaveErrorCode

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.

OSDBackgroundError

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.

SetTSVariable

The next step remove the computer from the OSD Collection.

RemoveFromOSDCollection

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.

Disable Computer account

Then we use a small script that will fail the Task Sequence with the original error code that we saved in the variable before.

SetErrorCode

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.

TaskSequenceError

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.

TSError2

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.

OSDBackground Addon

Thanks Johan Schrewelius for creating OSDBackground!!

9 thoughts on “Error handling in TS without MDT using OSDBackground”

  1. jf4x says:
    July 17, 2017 at 7:57 pm

    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

    Reply
  2. Zolabus says:
    April 10, 2018 at 11:52 am

    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

    Reply
  3. Aravinth says:
    November 26, 2018 at 7:03 pm

    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

    Reply
  4. Oleg says:
    March 3, 2020 at 1:15 am

    Can this be used during Win10 Upgrade TS?

    Reply
    1. Oleg says:
      March 3, 2020 at 1:16 am

      Tried to use it and it doesn’t produce anything. Maybe I’m missing something?

      Reply
    2. Oleg says:
      March 3, 2020 at 2:06 am

      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.

      Reply
    3. Jörgen Nilsson says:
      March 5, 2020 at 10:33 pm

      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

      Reply
  5. Pingback: Teams Channel Notification when OSD Fails - Systems Management Squad
  6. Andreas says:
    August 14, 2020 at 11:51 am

    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

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

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

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Recent Posts

  • Creating better Driver update groups
  • Windows 11 initial Start Menu with Intune
  • Application Control for Business and the story of the unsigned WIX dll’s
  • MMUGSE – Meetup October 24 2026
  • Windows 365 Link – a week and some
©2026 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT