In this article I will demonstrate how to add and remove an application with source files and an application bundle in the Microsoft Deployment Toolkit (MDT) using the GUI and PowerShell.

MDT allows you to create operating systems images, and you also can add your own applications, packages, and device drivers. The toolkit offers many options for application management; for instance, you can organize applications in different folders and handle application dependencies. You also can create application bundles, which essentially is just a list of applications. This allows you to combine all applications for a specific branch of your company and install them all together.

Understanding applications in MDT ^

All applications in MDT are located in the Applications node of the Deployment Share.

As you can see in the screenshot below, three options are available when you create an application:

In this article I will focus on application with source files and application bundle.

MDT Applications types

MDT Applications types


Application with source files

When you create an application with source files, the following two things will happen:

  • Application sources will be added to the applications folder of your Deployment Share.
  • Information about the application will be added to the Control\Applications.xml

The screenshot below gives an example about the application information.

Application with sources - Summary

Application with sources - Summary

As mentioned above, the applications folder stores the application sources:

Applications folder in Deployment Share

Applications folder in Deployment Share

MDT saves the application information in the Applications.xml file.

Application information with sources in Applications xml

Remark: When you create an application, not all options are available. You can find more options in your application properties General tab:

  • Comments
  • Display name
  • Hide this application in the Deployment Wizard
  • Enable this application
Application with sources - General tab

Application with sources - General tab

The Details tab provides these options:

  • Reboot the computer after installing this application
  • This can run on any platform
  • This can run only on the specified client platforms
Application with sources - Details tab

Application with sources - Details tab

Application bundle

An application bundle is a bit different than an application with source files. For instance, when you create an application bundle, no applications folder will be added.

The Applications.xml below belongs to an application bundle:

Application bundle - Applications xml

Application bundle - Applications xml

If you create an application bundle, the application information will be added as shown below:

Application bundle -Summary

Application bundle -Summary

In the General and Details tabs of your application, you can find the same options as with an application with sources.

Application bundle - General tab

Application bundle - General tab

Application bundle - Details tab

Application bundle - Details tab

Adding an application to the Deployment Share ^

Adding an application with source files

Instead of adding all this information with the GUI, you can use PowerShell to automate the task. When you create an application with MDT, a click on the View Script button shows you the corresponding PowerShell script.

Application with sources - View Script

Application with sources - View Script

Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "C:\DeploymentShare"
Import-MDTApplication -path "DS001:\Applications" -enable "True" -Name "4Sysops MyApplication 1" -ShortName "MyApplication" -Version "1" -Publisher "4Sysops" -Language "EN" -CommandLine "MyCommandLine" -WorkingDirectory ".\Applications\4Sysops MyApplication 1" -ApplicationSourcePath "C:\MyApplication" -DestinationFolder "4Sysops MyApplication 1" –Verbose

We will use this script to add our application with PowerShell. Because this basic script doesn’t show all available options, I’ll explain now how you can add more options.

This script is composed of three parts:

  • Import-module -> Loads the Deployment Toolkit module.
  • New-PSDrive -> Creates a PSDrive to import the application. It will be removed automatically.
  • Import-MDTApplication -> Integrates the application in the Deployment Share.

As mentioned above, you can set more options using PowerShell. I’ve listed all parameters that you can apply:

  • -Path -> Path of the Deployment Share applications folder.
    • Type: String
    • Status: Mandatory
  • -Enable -> Enable this application.
    • Type: Boolean
    • Status: Optional
  • -Reboot -> Reboot the computer after installing the application.
    • Type: Boolean
    • Status: Optional
  • -Hide -> Hide the application in the deployment wizard.
    • Type: Boolean
    • Status: Optional
  • -Name -> Your application name.
    • Status: Mandatory
    • Type: String
  • -ShortName -> Your application’s short name.
    • Type: String
    • Status: Mandatory
  • -Comments
    • Type: String
    • Status: Optional
  • -Version -> Version of your application
    • Type: String
    • Status: Optional
  • -Publisher -> Publisher of your application.
    • Type: String
    • Status: Optional
  • -Language -> Language of your application.
    • Type: String
    • Status: Optional
  • -CommandLine -> Command that will be used to install your application.
    • Type: String
    • Status: Mandatory
  • -WorkingDirectory -> Path of your Deployment Share. è “.\Applications\<Your Appli>”
    • Type: String
    • Status: Mandatory
  • -ApplicationSourcePath -> Sources of your applications.
    • Type: String
    • Status: Mandatory
  • -DestinationFolder -> Path on your Deployment Share.
    • Type: String
    • Status: Mandatory
  • SupportedPlatform -> The client platforms where the application can run.
    • Type: String
    • Status: Optional
  • UninstallKey -> Method to uninstall the program.
    • Type: String
    • Status: Optional
  • Dependency -> Application to be installed before the current one. You can add multiple applications here.
    • Type: You have to use the MDT application GUID.
    • Status: Optional

The below script allows you to add an application to your Deployment Share. It will ask for these parameters:

        • Name, Publisher, Version, Language, Comments, ShortName, DisplayName, Source, Commandline.
        • Required fields are Name, ShortName, Source, CommandLine.
Script to add an application with sources

Script to add an application with sources

The name of the application is composed of the values of the parameters Publisher, Name, and Version. In the script, the name is stored in the variable $Application_Complete_Name. In MDT, the working directory looks like this: “.\Applications\name”; in the script, it is stored in the variable $Application_Working_Directory. The variable $module must contain the path to theMicrosoftDeploymentToolkit.psd1 file. It is usually located in C:\Program Files\Microsoft Deployment Toolkit\bin. The variable $Deploymentshare must contain the path to your Deployment Share folder.

In the script below, I create the PSDrive DSAppManager to ensure that it’s an unused Drive.  After the script runs, this message will be displayed:

Output when you run the script to add an application with sources

Output when you run the script to add an application with sources

Param
	(
		[Parameter(Mandatory=$true)]
		[String]$name,			
		[Parameter(Mandatory=$true)]
		[AllowEmptyString()]		
		[String]$publisher,			
		[Parameter(Mandatory=$true)]
		[AllowEmptyString()]				
		[String]$version,			
		[Parameter(Mandatory=$true)]
		[AllowEmptyString()]						
		[String]$language,			
		[Parameter(Mandatory=$true)]
		[AllowEmptyString()]						
		[String]$comments,			
		[Parameter(Mandatory=$true)]
		[AllowEmptyString()]						
		[String]$shortname,			
		[Parameter(Mandatory=$true)]
		[AllowEmptyString()]						
		[String]$displayname,			
		[Parameter(Mandatory=$true)]
		[String]$source,				
		[Parameter(Mandatory=$true)]
		[String]$commandline
	)
	
$Application_Complete_Name = "$publisher $name $version" 
$Application_Complete_Name = $Application_Complete_Name.trim()
$Application_Working_Directory = ".\Applications\$Application_Complete_Name"
$module = "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
$deploymentshare = "C:\DeploymentShare"
Import-Module $module				
$PSDrive_Test = get-psdrive
If ($PSDrive_Test -eq "DSAppManager")
	{
		Remove-PSDrive -Name "DSAppManager"		
		New-PSDrive -Name "DSAppManager" -PSProvider MDTProvider -Root $deploymentshare								
	}
Else
	{
		New-PSDrive -Name "DSAppManager" -PSProvider MDTProvider -Root $deploymentshare		
	}			
			
Import-MDTApplication -path "DSAppManager:\Applications" -enable $true -reboot $false -hide $false -Name $Application_Complete_Name -ShortName $shortname -DisplayName $displayname -Comments $comments -Version $version -Publisher $publisher -Language $language -CommandLine $commandline -WorkingDirectory $Application_Working_Directory -ApplicationSourcePath $source -DestinationFolder $Application_Complete_Name -Verbose

Adding an application bundle

Application bundle - View Script

Application bundle - View Script

When you click View Script, you will see the PowerShell commands below:

Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"

New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "C:\ DeploymentShare "

import-MDTApplication -path "DS001:\Applications" -enable "True" -Name "4sysops MyBundle 1" -ShortName "MyBundle" -Version "1" -Publisher "4sysops" -Language "EN" -Bundle –Verbose

Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "C:\ DeploymentShare "
Import-MDTApplication -path "DS001:\Applications" -enable "True" -Name "4sysops MyBundle 1" -ShortName "MyBundle" -Version "1" -Publisher "4sysops" -Language "EN" -Bundle –Verbose

Script to add an application bundle

The next script allows you to add an application bundle to your Deployment Share. It works as the previous script, with the only difference that these parameters are unavailable:

  • -CommandLine
  • -WorkingDirectory
  • -ApplicationSourcePath
  • -DestinationFolder

To create a bundle, you have to add the parameter -Bundle to the Import-MDTApplication cmdlet, which will then expect the following parameters:

  • Name, Publisher, Version, Language, Comments, DisplayName, ShortName
Script to add application bundle

Script to add application bundle

After you have executed the script, you will get the below message:

Output when you run the script to add application bundle

Output when you run the script to add application bundle

Param
	(
		[Parameter(Mandatory=$true)]
		[String]$name			
	)
		
$module = "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
$deploymentshare = "C:\DeploymentShare"	
Import-Module $module	
$PSDrive_Test = get-psdrive
If ($PSDrive_Test -eq "DSAppManager")
	{
		Remove-PSDrive -Name "DSAppManager"		
		New-PSDrive -Name "DSAppManager" -PSProvider MDTProvider -Root $deploymentshare								
	}
Else
	{
		New-PSDrive -Name "DSAppManager" -PSProvider MDTProvider -Root $deploymentshare		
	}			
			
Remove-Item -path "DSAppManager:\Applications\$name" -force –verbose

Removing an existing application from the Deployment Share ^

Application with sources

As with the previous procedure, when you remove an application from your Deployment Share using MDT, the View Script button shows you the corresponding PowerShell command:

remove-item -path "DS001:\Applications\4Sysops MyApplication 1" -force –verbose

  • -Path -> The path to your Deployment Share.
  • -Force -> Delete these items, even if there are copies in other folders.
  • -Verbose -> Add an entry to log file Audit.log.

Script to remove an application with sources

The below script allows you to remove an application with sources from your Deployment Share.

It only asks for the application name, and you should run it in the folder of the application that you want to remove.

Script to remove an application

Script to remove an application

Output of the script to remove an application

Output of the script to remove an application

Param
	(
		[Parameter(Mandatory=$true)]
		[String]$name			
	)
		
$module = "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
$deploymentshare = "C:\DeploymentShare"	
Import-Module $module	
$PSDrive_Test = get-psdrive
If ($PSDrive_Test -eq "DSAppManager")
	{
		Remove-PSDrive -Name "DSAppManager"		
		New-PSDrive -Name "DSAppManager" -PSProvider MDTProvider -Root $deploymentshare								
	}
Else
	{
		New-PSDrive -Name "DSAppManager" -PSProvider MDTProvider -Root $deploymentshare		
	}			
			
remove-item -path "DSAppManager:\Applications\$name" -force –verbose

Application bundle

As usual, the View Script button gives you the command to remove the application bundle

remove-item -path "DS001:\Applications\4sysops MyBundle 1" -force -verbose

  • -Path -> Your application folder on your Deployment Share.
  • -Force -> Delete these items, even if there are copies in other folders.
  • -Verbose -> Add an entry to the log file Control\Audit.log.

To remove an application bundle from the MDT, you can use the same script as for an application with sources.

0
4 Comments
  1. Mike 5 years ago

    Is it possible to use PowerShell to add an application to a bundle?

    0

    • Author
      Damien VAN ROBAEYS 5 years ago

      Hello Mike, indeed you can use Powershell to do this. I don't think there is a MDT Powershell cmdlet to do this, but accourind to me, you can proceed as below.

      When you add applications in a bundle, these application will be added as dependencies. These apps are located in the dependencies Tab from MDT.

      To add an existing application in an existing bundle, you can use Powershell to modify the Control\Applications.xml file to add a new dependency.

      <Dependency><Application_GUID></Dependency>

      If you want I can send you a Powershell script to do this xml modification.

      0

  2. Mike 5 years ago

    I'll take a look at that Damien and if I can't figure it out I'll bug you for the script.

    0

  3. v-juanm 4 years ago

    In case of conflict status avoid application is already in place, open your applications.xml in your Deployment Share

    Sample
    F:\W10_1709_Creation\Control folder

    If you get that application that you are trying to add is already listed in applications.xml, remove the application from applications.xml

    NOTE: Be sure to close all your DeploymetnWorkBench consoles, other wise to avoid OS warning applications.xml is open

    0

Leave a reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account