Allow a user to delay a Windows 10 upgrade task sequence

Upgrading Windows 10 (e.g. v1511 to v1607) is easy using the upgrade task sequence in SCCM. Unfortunately it is not as user friendly as we would like, most notably there is no warning to the user that an upgrade is about to take place (when you set the upgrade task sequence to required). To fix this issue we use PowerShell App Deployment Toolkit to warn the user and allow them to delay the upgrade task sequence.

Create a package using PowerShell App Deployment Toolkit but do not create a program. Include serviceui.exe (included with MDT) in your source folder. In deploy-application.ps1 add the following code:

[string]$installPhase = 'Pre-Installation'

##Show Welcome Message
$AnyLoggedOnUsers=Get-LoggedOnUser -ErrorAction SilentlyContinue
if ($AnyLoggedOnUsers.Count -gt 0)
{
	$TSProgressUI = New-Object -COMObject Microsoft.SMS.TSProgressUI
	$TSProgressUI.CloseProgressDialog()
	Show-InstallationWelcome -PersistPrompt -AllowDefer -DeferTimes 3
}

In the first step of your upgrade task sequence set the error timeout dialog. We are setting the error timeout dialog to 1 so if/when a user delays the upgrade task sequence they do not see the task sequence error message.

In the second step of your upgrade task sequence create a run command line with the following

ServiceUI.exe -process:TSProgressUI.exe %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File Deploy-Application.ps1

Add a query wmi option on the run command

SELECT * FROM Win32_ComputerSystem WHERE UserName != NULL

That’s all the additions you need to make to your upgrade task sequence.

If no user is logged on it will NOT run the PowerShell App Deployment Toolkit script. It will just continue on with next step in the task sequence.

If a user is logged on it WILL run the PowerShell App Deployment Toolkit script and WILL NOT continue with next steps until user continues the install.

NOTE: The above WMI query will not work if you are RDP’d in.

If the user delays the upgrade then the task sequence will fail. The task sequence will try again on its next scheduled time (I set mine to rerun every day if the previous attempt failed).

Sources:
http://psappdeploytoolkit.com/forums/topic/does-running-as-a-task-sequence-always-disable-interactive-mode/

  1. Thanks for posting Josiah –
    We are looking to do this at my company. MS really needs to add a defer option for required TS deployments. I have a question regarding the “rerun if previous attempt failed” option. My concern is if the user runs the upgrade TS and it fails legitimately, will it try to run again automatically on the next scheduled run? Otherwise it makes sense for the defer logic.

    1. I did not specifically test your scenario. I set the upgrade task sequence as required a few weeks in the future and then let the users know its available. I have the upgrade task sequence only deployed to v1511 computers, so if the task sequence did fail and it reverted back to v1511 the task sequence would still be deployed to them so it would re-run.

  2. Great, thanks again. Testing this solution now as a defer option would be ideal. For now we are using a prompt with countdown as a final warning before the upgrade starts. Better than nothing.

        1. Here is what my code looks like:

          ##*===============================================
          ##* PRE-INSTALLATION
          ##*===============================================
          [string]$installPhase = ‘Pre-Installation’

          ## Show Welcome Message
          $AnyLoggedOnUsers=Get-LoggedOnUser -ErrorAction SilentlyContinue
          if ($AnyLoggedOnUsers.Count -gt 0)
          {
          $TSProgressUI = New-Object -COMObject Microsoft.SMS.TSProgressUI
          $TSProgressUI.CloseProgressDialog()
          Show-InstallationWelcome -PersistPrompt -AllowDefer -DeferTimes 3
          }

          ## Show Progress Message (with the default message)
          #Show-InstallationProgress

          ##

          ##*===============================================
          ##* INSTALLATION
          ##*===============================================
          [string]$installPhase = ‘Installation’

          ##

          ##*===============================================
          ##* POST-INSTALLATION
          ##*===============================================
          [string]$installPhase = ‘Post-Installation’

          ##

          ## Display a message at the end of the install
          ## Show-InstallationPrompt -Message ‘You can customize text to appear at the end of an install or remove it completely for unattended installations.’ -ButtonRightText ‘OK’ -Icon Information -NoWait

          # If installation needs to restart give them 5 hours but remind them when there are 15 minutes left
          #Show-InstallationRestartPrompt -Countdownseconds 18000 -CountdownNoHideSeconds 900

          1. Is this all that is in your powershell file? Did you delete the other stuff out besides this part?

  3. Seems to be working up until i hit the “defer” button. Once i do so the Powershell App Deployment Toolkit window closes but the task sequence doesn’t fail. It just sits there doing nothing at all. The ServiceUI.exe is still running in the background. The task sequence doesn’t fail until i manually end the ServiceUI.exe task.

    Is there something missing or will the task sequence fail on its own after a certain period of time? I waited about 10-15 min.

      1. I corrected the first issue and it looks like the task sequence fails correctly when you hit defer.
        Now I’ve got the opposite issue (which I hadn’t tested before) and if you just click on “continue” nothing happens. The background process of the ServiceUI just keeps running and the task sequence stalls out.
        What is the expected behavior of the script when you click on continue? Shouldn’t it just complete itself and move on to the next step in the task sequence?

        1. Yes, it should just exit successfully and go onto the next step. There should be a log that’s generated when the step is ran, what does it show in there? Does it show as exit code 0?

          1. I figured it out. Your quoted code in the comments above was the key for some reason.
            Commenting out the post-installation message items is what it needed. Otherwise it was waiting forever for an installation to complete or something like that.

            Thanks for your post. I look like a genius to my boss for now having a way to defer an upgrade. Upgrades are always a scary thing. Especially with the odd hours people keep (even in a k-12 school district like ours) and so he’s always worried about deploying in the middle of somebody’s work.

  4. Hi,

    Great article. We have been looking at being able to display user prompt in a task sequence.

    I’m getting a 0xFFFFFFFF error when trying to run the command “ServiceUI.exe -process:TSProgressUI.exe %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File Deploy-Application.ps1”

    Any ideas what could be causing the error?

    Process completed with exit code 4294967295 TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    !——————————————————————————————–! TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Failed to run the action: Windows Install Warning.
    Unknown error (Error: FFFFFFFF; Source: Unknown) TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Set authenticator in transport TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Set a global environment variable _SMSTSLastActionRetCode=-1 TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Set a global environment variable _SMSTSLastActionSucceeded=false TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Clear local default environment TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Let the parent group (Preparation) decides whether to continue execution TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    The execution of the group (Preparation) has failed and the execution has been aborted. An action failed.
    Operation aborted (Error: 80004004; Source: Windows) TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Failed to run the last action: Windows Install Warning. Execution of task sequence failed.
    Unknown error (Error: FFFFFFFF; Source: Unknown) TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Set authenticator in transport TSManager 3/14/2018 1:41:23 PM 9364 (0x2494)
    Task Sequence Engine failed! Code: enExecutionFail TSManager 3/14/2018 1:45:00 PM 9364 (0x2494)
    **************************************************************************** TSManager 3/14/2018 1:45:00 PM 9364 (0x2494)
    Task sequence execution failed with error code 80004005 TSManager 3/14/2018 1:45:00 PM 9364 (0x2494)

    Thanks

  5. This is what i am getting when I run this in an elevated cmd prompt:

    ServiceUI.exe -process:TSProgressUI.exe %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File Deploy-Application.ps1

    =======================
    Matched Processes
    =======================
    Process Not Found: [TSProgressUI.exe]

    =======================
    Exiting with [-1]
    =======================

  6. Great tool !!!!
    you can change the delay time between the installation retries?
    What is the default time of this retries? 1 day? where can I change the value?
    Thanks.

  7. great article
    I have a scenario what if machine is locked, user still logged in does it continue or it sits on pop up screen?

Leave a Reply

Up Next:

Citrix Receiver install hangs during task sequence

Citrix Receiver install hangs during task sequence