MDT: Running a PowerShell Script During a Deployment

In this tutorial, I will explain how to run a PowerShell script (.ps1 file) during a deployment with MDT.

Copy the ps1 1 file to the Scripts folder in the DeploymentShare folder.

DeploymentShare folder

Open the properties of the task sequence then add a task of type Run Command Line 1 .

Move the task to the desired location using the arrows then edit the properties: name the task 1 . In the Command line 2 field enter powershell.exe -file "%ScriptRoot%\file-name.ps1". In the Start in 3 field indicate %ScriptRoot% then validate by pressing the Apply button 4 and OK 5 .

The next time you deploy with this task sequence, the PowerShell script will be executed.

Romain Drouche

Romain Drouche

System Architect | MCSE: Core Infrastructure

An IT infrastructure expert with over 15 years of hands-on experience. Currently serving as a Systems and Network Project Manager and Information Systems Security (ISS) Lead, I leverage my expertise to ensure the reliability and security of technological environments.

GHinM▶