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.




2 thoughts on “MDT: Running a PowerShell Script During a Deployment”

Leave a Comment