If you have been working with SCCM deployments long enough, eventually you may encounter a need to display a window during running Task Sequence. It may be just a simple message box advising user to save all their data, up to more complex solutions with multiple options for the users. Whichever it might be, you first design and test your solution outside of Task Sequence and it works fine, then you try to run this inside of Task Sequence and… nothing happens.
This article will briefly guide you through how to show a custom message (topic covered widely on the net already), as well as how to ensure it doesn’t fail your Task Sequence in certain circumstances.
First of all, put together your PowerShell script with your custom window. As mentioned before, this can be a simple message box or a more complex solution, for example setting Task Sequence variables based on user’s choices – the sky is the limit. If you are planning a more complex solution, try building your own window using PowerShell and WPF – there is a brilliant tutorial on the topic that I can’t recommend enough: https://foxdeploy.com/2015/04/10/part-i-creating-powershell-guis-in-minutes-using-visual-studio-a-new-hope/
Once you have your script at hand, grab your latest MDT source media and copy ServiceUI.exe from Toolkit\Tools\x86 subfolder (you can use x86 executable on both x86 and x64 platforms.) to folder with your script’s source files. Next, wrap it all up in a Package (do not create a Program).
Last thing you need to do, is to call your PowerShell script through ServiceUI using the following syntax:
ServiceUI.exe -process:TSProgressUI.exe %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -nologo -File Defer-Installation.ps1
We are done, right? Not quite. This will work just fine, as long as there is a user logged on. This may not always be the case if you are deploying your Task Sequence as Required. When Task Sequence runs this step with no user is logged on, it will typically fail with the follow error:
Process completed with exit code 4294967295 (...) ======================= Process Not Found: [TSProgressUI.exe] ======================= Exiting with [-1] ======================= (...) !--------------------------------------------------------------------------------------------! Failed to run the action: Defer installation script *. Unknown error (Error: FFFFFFFF; Source: Unknown)
Now, you can easily avert this failure by applying a WMI query on the Task Sequence step. You will find that some suggest using the following query:
SELECT * FROM Win32_ComputerSystem WHERE Username IS NOT NULL
This query checks if a user is logged on, however it is only limited to the local console session. Any user logged on via RDP will not be registered in Win32_ComputerSystem class. This solution might be good enough for your scenario, but if you want to cater for RDP users, you should use slightly different query. The original error message told us what the underlying problem was – the TSProgressUI.exe was not running. This means the Task Sequence was running, but it hasn’t spawned the process responsible for showing the progress, as there was no users to create it for. Therefore, our query should check if TSProgressUI.exe exists.
SELECT * FROM Win32_Process WHERE Name = "tsprogressui.exe"
This will work for both users logged in locally, as well as those logged in via RDP.
Thanks for this Blog, very useful information. I work actually for in place upgrade Task sequence to migrate all computer to 1607 -> 1803. i create my own GUI with Xaml and powershell but i want to add new item to defer task sequence to end user but i have no idea how i can do that .. it’s more difficult .
I see you have dit it in your HTA GUI .. So can you help me please? can you if its possible share you powershell code for this features ?
Thanks in advance
Sorry for my english, im french ….
The screenshot was actually a teaser of upcoming blog post! I am planning to share on how this can be achieved, however I am unable to confirm the timescales when I will get the time to write the article…
please can you share the coding for this prompt ?
Such a message box is just what I was looking for.
Have you finished your coding or do you need a tester ?
nice message box. I was looking all the time for such a cool thing.
Can you share your .ps1-Code with us ?
Thanks in advance
please let me know if the coding finished .it will be great if you share the coding . thanks
hello, it’s possible to have the source code of this form to upgrade Windows 10 please.
Excellent work on the Deferral UI, can the code be made available to public? Thannks.