Using the Microsoft Deployment Toolkit (MDT) as portable application allows to simplify the OS deployment process in branch offices. In this post you will also learn how to create and update a Deployment Share for the portable MDT.

In our organization we manage OS images centrally and we don’t want the local IT departments to modify our master images. To allow the local support staff to add specific applications to our images, we send them a portable version of the MDT. This way, they don’t have to install the toolkit which would be too complicated for the local support staff.

Using the MDT as portable application

The MDT installation files are located by default in “C:\Program Files\Microsoft Deployment Toolkit”. The ADK installation files are located by default in “C:\Program Files\Windows Kits\10”.

The use of MDT without installing it can be achieved in three steps. You start by creating two folders that will contain respectively, required files for MDT and required files for ADK.

See below, what these folders should contain:

  • MDT_Module è Required files from MDT installation
  • ADK_Module è Required files from the ADK installation

Note: If you already have a Deployment Share make sure you use the same version of MDT you used to create the deploy contents.

The MDT_Module folder should contain the folders below from “C:\Program Files\Microsoft Deployment Toolkit”.

MDT_Module folder content

MDT_Module folder content

The ADK_Module folder should contain the folders below from “C:\Program Files\Windows Kits\10”.

ADK_Module folder content

ADK_Module folder content

The Assessment and Deployment Kit folder should contain the folders below:

Assessment and Deployment Kit folder content

Assessment and Deployment Kit folder content

The Deployment Tools folder should contain the folders below:

Deployment Tools folder content

Deployment Tools folder content

The Windows Preinstallation Environment (PE) should contain the folders below:

Windows PE folder content

Windows PE folder content

The second step is to create two registry keys that will contain the paths to both (MDT_Module and ADK_Module folders).

The first key that you should create is “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Deployment 4”.

In this key, you create a string “Install_Dir” with value the path of the MDT_Module folder.

Registry Key for MDT to create

Registry Key for MDT to create

 The second key that you should create is “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits” then create a Key “Installed Roots”.

In this key, you create a string “KitsRoot10” with the value of the path of the ADK_Module folder.

Registry Key for ADK to create

Registry Key for ADK to create

The following script, will allow you to automate the registry key creation.

This script is composed of four parts:

  • Creates the Deployment 4 Key in HKLM:\SOFTWARE\Microsoft\
  • Creates the String Install_Dir with value the path of the MDT_Module folder
  • Creates the Key Windows Kits in HKLM:\SOFTWARE\Microsoft\
  • Creates the Key Installed Roots in HKLM:\SOFTWARE\Microsoft\
  • Creates the String KitsRoot10 with value the path of the ADK_Module folder
# $MDT_Module = "<Your_ModuleFolder_Path"
# $ADK_Module = "<Your_WindowsKitsFolder_Path"

# 1 / Part 1
$Deployment4_Key = "Deployment 4" 
$HKLM_Location = "HKLM:\SOFTWARE\Microsoft"
$MDT_Deployment4 = "HKLM:\SOFTWARE\Microsoft\$Deployment4_Key"
New-Item -Path $HKLM_Location -Name $Deployment4_Key
		
# 2 / Part 2			
New-ItemProperty -Path "$MDT_Deployment4" -Name "Install_Dir" -PropertyType String -Value "$MDT_Module"

# 3 / Part 3			
$WinKits_Key = "Windows Kits" 
$InstalledRoots_Key = "Installed Roots" 
$InstalledRoots_Key_Creation = "HKLM:\SOFTWARE\Microsoft\Windows Kits\$InstalledRoots_Key"
$WindowsKits_Location = "HKLM:\SOFTWARE\Microsoft\Windows Kits"
New-Item -Path $HKLM_Location -Name $WinKits_Key
New-Item -Path $WindowsKits_Location -Name $InstalledRoots_Key

# 4 / Part 4				
New-ItemProperty -Path "$InstalledRoots_Key_Creation" -Name "KitsRoot10" -PropertyType String -Value "$ADK_Module"

Once it’s done, create a PSDrive that will be mapped to the Deployment Share folder. The script below allows you to automate the tasks mentioned earlier: (a) import the MDT module and (b) create a PSDrive “DSManager.

$module = "<MicrosoftDeploymentToolkit_Path>"
$deploymentshare = <DeploymentShare_Path>
Import-Module $module	
$PSDrive_Test = get-psdrive
If ($PSDrive_Test -eq "DSManager")
	{
		Remove-PSDrive -Name "DSManager"		
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare								
	}
Else
	{
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare		
	}
New PSDrive DSManager

New PSDrive DSManager

Consider the following variables for all the scripts used in this article:

  • $module -> location of the five files mentioned above ($module=”c:\MDT_module”)
  • $Deploymentshare -> location of your Deployment Share ($deploymentshare=”c:\deploymentshare”)

So far, we’ve learned how to use the MDT module. Now let’s create a Deployment Share, then update it, and finally, add/remove an item using the above method.

Creating the Deployment Share

The Deployment Share includes your entire master image configuration (operating systems images, applications, language packs, etc.). This is actually the main part of the toolkit.

With the help of the New Deployment Share wizard, you can easily create the Deployment Share. The screenshot below gives an example about the default Deployment Share information.

New Deployment Share Wizard summary

New Deployment Share Wizard summary

Instead of adding this information with the GUI, you can use PowerShell to automate the task. The script is below creates the Deployment Share and is composed of four parts:

  • Asks for your Deployment Share’s location and name
  • Creates the Deployment Share folder
  • Imports the MDT module
  • Creates a new PSDrive “DSManager” mapped to your DeploymentShare
Param
	(
		[Parameter(Mandatory=$true)]
		[String]$path,			
		[Parameter(Mandatory=$true)]
		[String]$DeploymentShareName					
	)
	
$deploymentshare = "$path\$DeploymentShareName"	
New-Item -Path $deploymentshare -ItemType directory
$module = "<MicrosoftDeploymentToolkit_Path>"
$computer_name = $env:computername
Import-Module $module	
			
$PSDrive_Test = get-psdrive
If ($PSDrive_Test -eq "DSManager")
	{
		Remove-PSDrive -Name "DSManager"		
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare -NetworkPath "\\$computer_name\$DeploymentShareName$" -Verbose	
	}
Else
	{
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare -NetworkPath "\\$computer_name\$DeploymentShareName$" -Verbose 
	}

Updating the Deployment Share

Your Deployment Share needs to be updated if any changes are made in the boot image, for instance after adding drivers or changing the bootsrap.ini file.

Right-click on your Deployment Share and then “Update Deployment Share”.

Update Deployment Share in GUI

Update Deployment Share in GUI

Within the Update Deployment Share wizard, the options below are available:

MDT Update deploymentshare options

MDT Update deploymentshare options

  • Optimize the boot image updating process -> Update existing versions of the image files in your Deployment Share. Choose this option to reduce the amount of time required to update the boot images.
  • Completely regenerate the boot content -> This option will create a new version of all the image files in your Deployment Share. Choose this option if you want to force the creation of new images. However, this may take more time.

The PowerShell cmdlet used to update the Deployment Share is update-MDTDeploymentShare. As you can see in the following screenshot, the next script allows you to update your Deployment Share using one of three options:

  • Update and optimize the boot image updating process
  • Update, optimize, and compress the boot image updating process
  • Completely regenerate the boot images
PowerShell script - Update your Deployment Share choice

PowerShell script - Update your Deployment Share choice

This script is composed of three parts:

  • Loads the MicrosoftDeploymentToolkit module
  • Creates a new PSDrive “DSManager” mapped to the Deployment Share
  • Updates the Deployment Share depending on the option you have chosen

Note that script needs some time to complete.

[int]$xMenuChoiceA = 0
while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 4 ){
Write-host ""
Write-host "Update your Deploymentshare Choice"
Write-host "===================================================================="
Write-host "1. Update and optimize the boot image updating process"
Write-host "2. Update and optimize and compress the boot image updating process"
Write-host "3. Completely regenerate the boot images"
Write-host "4. Quit and exit"
Write-host ""
[Int]$xMenuChoiceA = read-host "Please enter an option 1 to 4" }
Switch( $xMenuChoiceA ){
  1{write-host $Update_With_Optimize}
  2{write-host $Update_With_Optimize_and_compress}
  3{write-host $Update_With_Regenerate}
  4{exit}
}
	
$module = "C:\MDT_module\MicrosoftDeploymentToolkit.psd1"
$deploymentshare = "C:\DeploymentShare"
Import-Module $module				
$PSDrive_Test = get-psdrive
If ($PSDrive_Test -eq "DSManager")
	{
		Remove-PSDrive -Name "DSManager"		
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare								
	}
Else
	{
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare		
	}			
			
$Update_With_Optimize = update-MDTDeploymentShare -path "DSManager:" -Verbose
$Update_With_Optimize_and_compress = update-MDTDeploymentShare -path "DSManager:" -Compress -Verbose
$Update_With_Regenerate = update-MDTDeploymentShare -path "DSManager:" -Force -Verbose

The screenshot below shows the script progress.

Update Deployment Share process

Update Deployment Share process

Adding an item to the Deployment Share

Adding an application

The PowerShell cmdlet used to add an application to the Deployment Share is Import-MDTApplication.

For an application bundle add -bundle to this cmdlet. In my previous post I explained how to add and remove an application in MDT with PowerShell and shared some scripts for the purpose.

Adding a package

In MDT, two package types are available:

  • OnDemand packages è Update or security packages
  • LanguagePack packages è Language packs you want to install on your Operating Systems

The PowerShell cmdlet used to add a package to the Deployment Share is Import-Mdtpackage.

You can use the script below to add a package to your Deployment Share. After you enter the name and the location of your package sources, the script will add the package to your Deployment Share. In this example the CAB file is located in C:\fr-FR_languagePack_Win10.

Param
	(
		[Parameter(Mandatory=$true)]
		[String]$sources			
	)
	
$module = "C:\MDT_module\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-mdtpackage -path "DSAppManager:\Packages" -SourcePath $sources –Verbose

After entering your package sources, the process will start.

Result of the PowerShell script to add a package

Result of the PowerShell script to add a package

Removing an item from the Deployment Share

The PowerShell cmdlet used to remove an item from a Deployment Share is Remove-Item. This cmdlet can be used to remove an application, package, or Operating System.

The next script (a) asks for the item name you want to remove; (b) imports the MDT module; (c) creates the PSDrive mapped to your Deployment Share; and (d) removes the selected item.

Subscribe to 4sysops newsletter!

Param
	(
		[Parameter(Mandatory=$true)]
		[String]$name			
	)
		
$module = "C:\MDT_module\MicrosoftDeploymentToolkit.psd1"
$deploymentshare = "C:\DeploymentShare"	
Import-Module $module	
$PSDrive_Test = get-psdrive
If ($PSDrive_Test -eq "DSAppManager")
	{
		Remove-PSDrive -Name "DSManager"		
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare								
	}
Else
	{
		New-PSDrive -Name "DSManager" -PSProvider MDTProvider -Root $deploymentshare		
	}			
			
remove-item -path "DSManager:\Packages\$name" -force -verbose
Powershell script to remove a package

Powershell script to remove a package

Result of the PowerShell script to remove a package

Result of the PowerShell script to remove a package

0 Comments

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2023

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