First, let me start by saying, yes, a frontend like UI++ is amazing, and if you’re looking for a really powerful way to do user driven task sequences, a quality community front end is a great way to go. This post, and the last couple posts are a simplified method to collect one piece of information, and act on it. The scripts are simple, 90% taken directly from Microsoft Learn pages, and modified to work in a task sequence with variables. I enjoy projects like this, it’s a couple hours of time to come up with this, build it, and test it. They help me to keep sharp with task sequence skills.
Code from today’s project taken from: Multiple selection list boxes – PowerShell | Microsoft Learn
I’ve made modifications to it including disable multi select, to return only one value. I’ve added a lot of notes to the code, so hopefully it would be easy to modify to your needs.
It’s all driven by task sequence variables for increased flexibility and transparency among your other task sequence editor team, something you could retrofit into the previous post.
Task Sequence Steps:
First step is to create the variables used in the script. Title, Text, List Options & Icon. The Icon is Base 64 Encoded.
Next is the PowerShell Script. garytown/OSD/UserInputListBox.ps1 The Script was written so it would work outside of the TS, so I could build most of it quick on my desktop before moving it into the Task Sequence to finish of testing.
Lastly, what I want to do with the Item that was selected, in this example, I’m setting another variable to a specific value based on the returned item. In the example, based on the location returned, a unique OU is set that will be used during the Apply Windows Setting step telling the OU the device should be added to when it joins the domain.
DEMO
Here the List Box launches, giving you a list of items to choose from. Once you click OK, the TS continues on, and it sets the OSDDomainOUName variable to the OU Path.
Above you can see the List Box popups up asking for you to pick something from the list. I picked Glenwood. Below you can see that the TSListOutPut was set to Glenwood, and in the next step, because it was set to Glenwood, it sets the OSDDomainOUName to the appropriate OU for that location.
Tips for Task Sequence when using PowerShell Forms.
Typically if you run a PowerShell script in the TS, it’s hidden, you don’t see it, so to make a Form popup, you need to actually call PowerShell from your script. It’s a little wonky, but it works:
I’m taking what is normally my entire script that I’d run, putting it into a scriptblock variable, and calling that with the Invoke-Command
NOTE, this works great in WinPE, to use in Full OS, you need to be more creative and leverage ServiceUI
start-process powershell.exe -ArgumentList "Invoke-Command -ScriptBlock {$script}" -NoNewWindow -Wait -PassThru -ErrorAction SilentlyContinue
Other use cases?
I could see several possibilities for something like this in a User Driven Task Sequence such as Application Installs, Setting Options, OS options, and any other questions with pre-defined sets that you want to allow users to choose.
GARYTOWN.COM
Hello, Thanks a bunch for this! I was wondering if you could point out what I’m missing, The list box is not appearing in windows PE (though it will when I put the code into Visual Studio Code on my desktop). I am PXE booting to a task sequence, I currently have it set in debug mode, all the variables seem to load in but then the list box never shows up so I can’t declare what OU I would like to place the device in. It then just proceeds to installing the OS. Thanks for your information regardless and any more help will be greatly appreciated.
You confirmed that the step is running? There isn’t a condition on the step that is preventing it from running? The SMSTS.log should tell you if the step is being skipped, as well as if there are any errors in your PS script, which should make the step fail.
I have got the box populating with all of my variables and they are set appropriately. I am struggling to find how to tell during the apply windows settings to reference the selected OU. I only see options to fill in the OU and enter in credentials to allow for adding to the domain
When you set variables with a Front End or user input, the TS will use those automatically. What I’d recommend doing is using debug mode in the Task Sequence, so after you set variables, you can see what they are, then watch what happens to your variables as rest of the steps go by.
I’d look at the Recast Posts for deeper details on those steps: https://www.recastsoftware.com/resources/configmgr-docs/task-sequence-basics/task-sequence-steps/settings/apply-windows-settings/
Gary, I’m trying to call this in a task sequence running in the full OS, and I cannot figure out the syntax for leveraging ServiceUI. You mentioned this but didn’t really give an example. Have you been able to make it work that way? Any help is sincerely appreciated.
Great info!
One thing about UI++ that is critical in my environment is the authentication with authorization. Different techs have permissions to different branches of the Workstations OU of the domain, so it’s important to push (force?) them down only the path they are allowed to use (in addition to denying other curious users). If you know of a way to do that with PowerShell combined with a set of these menus would eliminate the need for UI++.