The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • about.me

    Mikael Nystrom

    Mikael Nystrom

    OS Deployment Geek, Virtualization and System Center

    Mikael Nystrom is a Principal Architect at TrueSec

  • Archives

  • Meta

PowerShell is King – Bulk import applications I MDT

Posted by Mikael Nystrom on September 3, 2014

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: http://1drv.ms/1pGTvkA

/mike

2 Responses to “PowerShell is King – Bulk import applications I MDT”

  1. Mike said

    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. […] http://deploymentbunny.com/2014/09/03/powershell-is-king-bulk-import-applications-i-mdt/ […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 4,368 other followers

%d bloggers like this: