For users of Microsoft Deployment Toolkit (MDT) the ability to separate applications from the OS during deployment is a great feature. It is a much easier way to manage and deploy packages during the imaging process. Thankfully for Chocolatey users, MDT allows admins to have applications that do not have source files, in this case just a command like “choco install dropbox -y“.
Most organizations that use Chocolatey have their own hosted NuGet server which they use to deploy packages from. In this example I have setup a Chocolatey simple server. To see what packages are on your hosted server you can run “choco list –source<server>“.
So if you are using MDT and host a NuGet server how can we quickly import all your packages into MDT? We can use the MDT PSSnapin and Chocolatey CLI.
New-PSDrive -Name "MDT" -PSProvider "MDTProvider" -Root "E:\MDT"
$NuGetServer = 'nugetserver'
$NuGetPackages = choco list --source=$NuGetServer -r
ForEach ($NugetPkg in $NuGetPackages)
$PackageName = $NugetPkg.Split('|')
$Version = $NugetPkg.Split('|')
Import-MDTApplication -Path 'MDT:\Applications\test' -Name $PackageName -NoSource -Commandline "choco install $PackageName --source=$NuGetServer -y" -Shortname $PackageName -Version $Version -Enable "True"
In this example I have my own hosted NuGet server “nugetserver.domain.com”. I create a new PS drive to my MDT share “MDT”, use “choco list –source=nugetserver.domain.com” in order to get a list of my hosted packages and then loop through them to create an MDT application in the subfolder “test” for each package.
Just like that, Chocolatey deliciousness.