Task Sequence – Gather User Input – List Drop Down – PowerShell

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.


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.


2 thoughts on “Task Sequence – Gather User Input – List Drop Down – PowerShell”

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


Leave a Comment

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