Deployment

PowerShell is King – Bulk import applications I MDT

Often I need to import applications into the Deployment workbench and that is fine. The process is easy and fast, but it is boring and if you have more then 5 apps it is really boring. Based on the fact that almost all my apps in MDT is deployed using VB or PowerShell wrappers its is just one file in a folder and then there is a subfolder with the content. You don’t need to be a genius to figure out that 90% of all the apps pretty much have the same folder and file structure in the root of the application folder, so why don’t we use PowerShell to import all the apps based on some guessing?

The Logic:

This parts can be modified, edit, or you can add your own. Basically it reads the from the folder structure you specify and the script will then scan the folder structure for folders, assuming that every folder is an application. If it finds .msi, .msu, exe, .bat, .wsf, or .ps1 files it will then import them as applications. The important thing is that it will import the first “hit”. That means that you should store the real setup files in a subfolder, I usually use .\Source as the source folder. Here you can see the .WSF part logic

image
Part of the script.

The command line:

This is the tricky part, since there is no way to know that it will be a guessing game and the command line might need to be modified after import, but I rather modify 2-3 applications instead of importing all of them manually.

The default cmdline for all imported apps will be:

.EXE “$Install /q”
.MSI “msiexec.exe /i $Install /qn”
.MSU “wusa.exe $Install /Quiet /NoRestart”
.PS1 “PowerShell.exe -ExecutionPolicy ByPass -File $Install”
.WSF “cscript.exe $Install”

The Script:

The script is rather easy, it takes 2 parameters. The folder from where to import and the deployment share. You need to have MDT installed since it is using PowerShell cmdlets from MDT. The syntax for the script looks like this:

.\Import-MDTApps.ps1 -ImportFolder C:\Script\AppFolder -MDTFolder C:\MDTBuildLab

you could also add –Verbose if you like lots of text on the screen.

image
Output when using –Verbose during import.

You can download the script here: Files/Import-MDTApps.ps1 at master · DeploymentBunny/Files (github.com)

/mike

Categories: Deployment, MDT

Tagged as:

4 replies »

  1. This is excellent! This is just the sort of thing needed to help speed up the initial configuration of an MDT share.

    Very nice work!

  2. I’ve been testing another use case for this script that might prove helpful. In conjunction with Lenovo’s drivergrabber, this script makes installing their various drivers and utilities quite simple. Thanks.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.