Adding PowerShell support to WinPE using MDT 2012 RC1

After my last post about adding PowerShell support to WINPE I installed the latest MDT build.

Adding PowerShell support to WINPE is much easier using MDT.

Download MDT from connect Join the beta

Once installed add or create a deployment share.

Right click on the share and click properties.

Go to the Windows PE tab then click the features tab.


Select the features you want to add, click apply.

Close all the properties. Right click on the deployment share and click on update deployment share.

Once the update is complete you can use the WINPE ISO that MDT created to run PowerShell.


When PE starts up press F8 and run PowerShell by simply typing PowerShell




Make a Powershell Windows PE ISO

Oh I’ve been waiting a long time for this. PowerShell within WinPE

I was really excited about this functionality mainly for deployments but with the new ADK Windows Assessment and Deployment Kit (ADK) for Windows® 8 Consumer Preview it is possible to create WinPE ISO files and UDF/USB drives with a fully functioning PowerShell V3 shell inside.

Follow these instructions to install PowerShell within PE

These instructions are for installing PowerShell only, it does not include any instructions for adding network drivers or additional PE configurations required for production environments

Download the adkadksetup.exe from here

Install the ADK to a location of your choice

Once installed open the deployment and imaging tools as an administrator

Create the WinPE files by running the command copype amd64 c:winpe_amd64

or for x86

copype x86 c:winpe_x86

Create a directory like c:mount

Mount the PE boot.wim by running the command

dism /mount-wim /wimfile:C:winpe_x86mediasourcesboot.wim /index:1 /mountdir:C:mount

or for X64

dism /mount-wim /wimfile:C:winpe_amd64mediasourcesboot.wim /index:1 /mountdir:C:mount

once mounted add the required packages from the location you installed the .. Assessment and Deployment KitWindows Preinstallation Environmentx86WinPE_OCs

or for X64

Assessment and Deployment KitWindows Preinstallation Environmentx64WinPE_OCs

Please note..For my testing, I added every package apart from the as this caused issues within PE.

You can add the packages by running the DISM command..

dism /image:c:mount /add-package /packagepath:"C:Program Files (x86)Windows Kits8.0Assessment and Deployment KitWindows Preinstallation"

Once you have added the packages, drivers ect you must unmount the file and commit the changes with DISM

dism /unmount-wim /mountdir:c:mount /commit

The last step is to create the WINPE bootable image. By using the MakeWinPEMedia file you can create a udf or iso file from the contents of the c:winpe_x86 or x64 directory.

makewinpemedia /iso c:winpe_x86 c:winPE_x86.iso


makewinpemedia /iso c:winpe_x64 c:winPE_x64.iso

For this demonstration I created an ISO to test on Hyper-V

Powershell runs when typing the command Powershell into the command prompt.

Powershell is running on V3 within the host and get-command shows 366 cmdlets





Hey, I’m on the radio!

Last week I had the pleasure of being interviewed for the Get scripting podcast. In the podcast I talk about PowerShell and MDT, why PowerShell is the best thing since slice bread, and meeting men on the Severn bridge! Listen to the podcast here.


Get scripting podcast


!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src=”//”;fjs.parentNode.insertBefore(js,fjs);}}(document,”script”,”twitter-wjs”); !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src=”//”;fjs.parentNode.insertBefore(js,fjs);}}(document,”script”,”twitter-wjs”); !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src=”//”;fjs.parentNode.insertBefore(js,fjs);}}(document,”script”,”twitter-wjs”);



Monitoring MDT 2012 deployments

The latest beta release of MDT 2012 allows deployments to be tracked within the deployment workbench.

To set up remote monitoring right click on the deployment share, select properties then select the monitoring tab. Within this tab you can choose a monitoring host, and which ports to use for events and data. The default ports are 9800 and 9801.


Once a deployment has started the monitoring node within the workbench will display the progress of the deployment. By right clicking the deployment progress and selecting properties the progress of the deployment will be shown in more detail.


MDT monitors the progress of the deployment, the step, start and end, time elapsed, and any errors or warnings. MDT also assesses the deployment and will show options for remotely connecting to a machine if certain criteria have been met.

Remote desktop

The remote desktop button is displayed as default within the monitor. But will not establish a remote connection to WinPE, it will only connect to a system that has an operating system and remote desktop enabled.

DART remote control

The new version of DART (Diagnostic and recovery toolset) allows remote connections to be made to systems running WINPE.

The MDT monitoring tool will display a button for DART remote control if DART is detected running on the remote computer

VM remote control

The VM connection button allows a remote connection to a virtual machine running in Hyper-V.

MDT monitoring will display the button if Hyper-V integration components are detected running on the remote machine.


Windows PowerShell cmdlets for monitoring a deployment

The new MDT beta comes with PowerShell cmdlets to monitor the progress of a deployment.

As usual you can use the MDT cmdlets by running the PowerShell one liner

Add-PSSnapin ‘Microsoft.BDD.PSSNAPIN’

You must then attach a PSDRIVE to the deployment share

New-PSDrive -Name mdt -Root ‘D:deployment’ -PSProvider MDTPROVIDER

To get the monitoring data for a particular deployment run the get-mdtmonitordata cmdlet

Get-MDTMonitorData -Path mdt:

You will get back something like this


To stop monitoring the deployment use the remove-mdtmonitoringdata cmdlet

The task being monitored by MDT will then be removed

To add a monitor use the Set-MDTMonitorData cmdlet

Set-MDTMonitorData -Path mdt: -MacAddress ’00-15-5d-50-50-01′


This cmdlet would only allow me to load up the monitor if I used a MAC Address.

After loading up the monitor, get-mdtmonitordata reports that there are 2 deployments instead of 1 and when I try viewing the monitor node MDT will crash. Just a warning that this still is a Beta and issues like this will arise.

When I remove the extra monitor using PowerShell everything starts to work properly.


My way of remotely checking the progress of a deployment normally relies on somebody on the phone telling me its done or not. I also use the SLShareDynamicLogging customsettings property along with trace32 to monitor the real time logs.

By adding this monitoring capability MDT allows deployments to be carried out remotely with ease. I hope more functionality is added to this feature such as being able to view the logs.

MDT 2012 Beta 2 changes

I have just downloaded the MDT 2012 Beta 2. On first look it seems to be the same old MDT mmc look.

On opening the deployment share properties right click on deployment share, select properties everything looks different.


MDT Deployment share properties

MDT comes with 4 tabs. General, Rules, Windows PE, Monitoring

General and rules tab have not changed but within Windows PE MDT now has multiple tabs within to specify features and driver packages.



The last tab is the monitoring tab, with MDT 2012 deployments can be monitored from the monitoring node within the deployment share. The progress of the LTI deployment process is displayed as a percentage of completion. More on this later.


Within a task sequence properties there is now a run PowerShell step, MDT now allows PowerShell scripts to interact with task sequence variables and add to logs. PowerShell uses the Microsoft.BDD.TaskSequenceModule to create the TSENV: and TSENVLIST: Windows PowerShell drives. So I wasn’t going mad when I discovered this feature a few months ago in Beta1, more later.

PowerShell snapin improvements

Speaking of PowerShell MDT 2012 beta 2 has updated cmdlets for the monitoring solution. Once again, more on this later.


There have been some major improvements in Beta 2. Ill do some more digging and testing and post more about this update soon.

Enabling MDT items with with Windows PowerShell

If you use Windows PowerShell to access and manipulate your MDT deployment share you might have trouble enabling disabled items. To enable all the drivers within your deployment share run this PowerShell 1 liner within your out of the box drivers directory.

get-childitem|Foreach {Set-ItemProperty -Path $ -Name Enable -Value ‘True’}

To disable

get-childitem|Foreach {Set-ItemProperty -Path $ -Name Enable -Value ‘False’}

This one liner can also be used to enable and disable task sequences.

Thank you to Ben Hunter, senior program manager at Microsoft solution accelerators for helping me with this. Ben blogs at Deployment guys

MDT PowerShell database bulk import

Using PowerShell to read through a CSV file to add computer entries into the MDT 2010 Database

Tonight on Twitter there were a few mentions about a blog post importing computers in bulk into the MDT database using VbScript. The blog post in question was

Skatterbrainz had to convert a PowerShell Module into VBScript. The module can be found here.

I use the scripts contained within this module all the time, here is the command I use to Bulk import my computer items.

I have a CSV file with my computer information.

With each heading being a setting used in the database.


I then run the following script.

Import-Module mdtdb

$assets = Import-Csv “.Book2.csv”
connect-mdtdatabase -sqlserver yourdatabaseserver -database MDTDB4

ForEach($asset In $assets)


new-mdtcomputer -serialnumber $asset.SerialNumber -settings @{OSInstall=’YES’; OSDComputerName=$asset.OSDComputername; _SMSTSORGNAME=$asset._SMSTSORGNAME}


This will run through the CSV file and add them names and settings to the MDT database.

If you need to add different settings, just add SETTINGNAME=$asset.SETTINGNAME within the { }

So quite an easy way to quickly import items into the MDT database.