Add Microsoft Deployment Toolkit Applications with Chocolatey
The Microsoft Deployment Toolkit (MDT) allows Systems Administrators to automate and deploy the installation of Windows from a central location. We can build into this automation the ability to push out our applications so no user interaction is required.
By using the Chocolatey Package Manager the heavy lifting is done for us. No need to locate Installation Files or Silent Commands and import into MDT.
First create an installation script in your %DeploymentShare%\Scripts Folder. I created a new folder here called Chocolatey (%DeploymentShare%\Scripts\Chocolatey) and then created the following PowerShell Script – InstallChocolatey.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) choco source disable -n Chocolatey choco source add -n Internal -s https://chocoserver/nuget/trio/ choco source add -n Community -s http://chocoserver/nuget/Community/ --priority=10 choco feature enable -n allowGlobalConfirmation choco feature enable -n allowEmptyChecksums
The first line goes out and downloads and installs the Chocolatey Package. I then customize the Chocolatey Sources. We use an internal Choco Server for hosting internal packages and cache the Community Repo. By caching the repo this gets us around the rate limit by connecting directly. Last we enable some extra features in Chocolatey. That’s it for the script.
Add Chocolatey Install to MDT Task Sequence
Next we need to add the installation script to the MDT Task Sequence so Chocolatey gets installed.
- Open up MDT Workbench and open up your Task Sequence Properties.
- Locate the Custom Task Folder
- Click Add –> General –> Run PowerShell Script
- Give the new entry a Name: Install Chocolatey
- Enter the Powershell Script Location: %ScriptRoot%\Chocolatey\InstallChocolatey.ps1
- Click Apply
Add Chocolatey Applications
Now that we have our Task Sequence to to install the Chocolatey Package Manager, we need to add some applications.
Back in your MDT Workbench, Create a new Folder under applications called ‘Chocolatey’
Now right click this folder and choose ‘New Application’
You are given three choices
- Application with Source Files
- Application without Source files or elsewhere on the network
- Application Bundle
We need to choose the second option; because we are only passing the chocolatey command to install the application; click Next.
Give the Application a Name and click Next.
Enter the Chocolatey command to install the application and click Next until you complete the wizard.
Use the Chocolatey website (https://chocolatey.org/packages) to find your packages and installation commands.
Once you have finished adding your applications your MDT Workbench may look something like this.
Now I recommend that we add one more Application to the Chocolatey Folder, a bundle that will include all the applications you wish to install at once. This way you are not adding a task sequence for every application you want to add.
If you don’t want to do this you can skip this step.
Add Chocolatey Application Bundle
Right click the Chocolatey folder and choose ‘New Application’ again.
This time select the third option, Application Bundle and click Next. Give the new bundle a Name, StandardSOE and click Next until the wizard completes.
Once the wizard is completed, right click the application you created and choose Properties.
After the window opens choose the Dependencies Tab.
Click the Add Button and expand the chocolatey folder and choose the Applications you want to include in the Bundle and click OK and Apply and OK to close the Properties window.
Add Chocolatey Applications to MDT Task Sequence
Now that we have added the Applications, we need to go back and update the MDT Task Sequence to install them.
Open the MDT Task Sequence you edited earlier to add the Chocolatey installation.
Select the Install Chocolatey task you added.
Click Add –> General –> Restart Computer
This will add a Restart Computer Step after installing Chocolatey and before installing Applications.
Now choose the Restart Computer Task that has been added. Click Add –> General –> Install Application
Give the Install Application task a new name, Install Chocolatey Apps
Select the Install a Single Application Option, Click Browse and expand the Chocolatey folder and choose the Bundle Application you created above or choose a single application.
Repeat the steps above to Add Installation Application Tasks and choose Applications you want to add if you did not create a bundle.
Once you have added your Chocolatey Apps I like to add one more Restart Computer Task just to be safe that everything is working.
Once done click Apply and OK to save the Task Sequence.
You can now Boot from your LiteTouch ISO or WDS Server and choose your MDT Task Sequence and watch the Chocolatey goodness as it installs all your apps.