Basics of Deploying Scripts from MDT
The following sections are dedicated to Windows configuration changes from MDT, ConfigMgr or manually, many will be security based as I've a thing for making Windows more secure and lets face it, its still needed. As many of these scripts form the basis of my MDT Gold Image, this article will describe how to setup MDT.
For the deployment of custom content from MDT to the client I use the %scriptRoot% variable, this translates to the 'scripts' folder underneath the MDT Deployment share. Content is any file, script or program that is not deployed as an MDT Application, Driver, OS or Package. The other variable that is available is %deployRoot%, the MDT Deployment share root itself, however I tend not to use this for custom content.
The reasoning being behind this method is that its easy to use and reference, for me it provides a consistent approach to running scripts from MDT. Allows the entire MDT share to be picked up and copied to another server and have it deploying within an hour or so. There is no reason to amend the steps within the task sequences as they reference the MDT variables. Unlike some configs I've witnessed with hard coded task sequence steps eg \\I192.168.1.2\MDTShare\scripts\custom\.
Browse to the 'scripts' folder and create a working folder for all additional content named 'Custom'. Use any name that you see fit it doesn't have to be 'Custom'
For each new script create a new folder
Open 'Deployment Workbench', browse to or create a new client task sequence.
I'm a little OCD and like to organise my content with folders within the task sequence, so create a new folder for the custom configurations.
Click 'Add', 'General' and select 'Run PowerShell Script'
The physical path for the example below is 'D:\MDTDeployment\Scripts\Custom\Background', with the %scriptRoot% variable this is represented as '%scriptRoot%\Custom\Background'
Now that the basics have been covered we can now move on to deploying scripts following this process.