Task Sequence One-liners

What is a One-liner?

A one-liner is a single script line used to perform a task. This page contains a collection of useful one-liners that can be directly used as is within a Run Command-Line task sequence step. It’s important that they are just “one-line” so that no content is involved or downloaded by the target system to execute the one-liner.

Note that there are actually multiple lines of code involved with some of these, but through the power of PowerShell script blocks and pipelining, encapsulating the necessary commands in one-line is easy.

To use any one of these in a task sequence, simply add a new Run Command-line task and add the following:

powershell.exe -Command "& { >One-Liner< }"

Replace >One-Liner< with the desired one-liner from those listed below.

Pause

Pauses a task sequence for troubleshooting purposes. The pause is indefinite and based on the existence of a file called go.txt in the root of the system drive (X: in WinPE and typically C: in Windows). When you are ready to continue the task sequence, simply create the file. The one-liner will see the file, delete it, and then exit.

Hide BDEDrive

A common issue with in-place upgrade task sequences on systems with BitLocker enabled is that the BDEDrive volume ends up in a visible state instead of its usual hidden state. This is highly undesirable. This one-liner, placed near the end of the task sequence, will (re-)hide the volume.

Find System Drive Serial Number

This one-liner finds the serial number for the Windows system drive and stores it in a task sequence variable so it can later be used to find the drive letter of the system volume (see the next one-liner). This is useful if you need to drop to WinPE and perform offline image maintenance to the running OS. This one-liner should be run in the full OS.

Get Offline System Drive Letter

This one-liner uses the serial number for a drive to get the current drive letter for that drive and stores it in a task sequence variable. This one-liner should be run in WinPE and is useful because the drive letter may differ between the full OS and WinPE.