MDT PowerShell: Connect to MDT Function

 

Todays post is a time-saver function I wrote to connect to MDT shares. It allows me to just type Connect-MDT to import the module then enter to the MDT PSdrive.

It discovers the location of the MDT module(from the registry) and uses the Restore-MDTPersistentDrive cmdlet to restore the hosts existing MDT PSDrives. It will then set the location to the first MDT PSDrive thus eliminating the need to hard code the deployment share path. Ta-daa!

Connect-MDT

 

I’ve uploaded it to the Technet script repository and below is the simplified version.

http://gallery.technet.microsoft.com/Connect-to-MDT-Function-a5e7484c

Function Connect-MDT {

 If (!(Get-Module MicrosoftDeploymentToolkit)) {

     [String]$MDTInstall = ((Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Deployment 4').Install_Dir)

     Import-Module ($MDTInstall +'Bin\MicrosoftDeploymentToolkit.psd1') -Scope Global

 }

 $MDTPSDrive = Restore-MDTPersistentDrive -verbose

 Set-Location ($MDTPSDrive.Name +':')

}
Advertisements

About Andrew Barnes

A Scripting and Deployment Specialist.
This entry was posted in MDT 2010, MDT 2012, MDT 2013, PowerShell and tagged , , . Bookmark the permalink.

5 Responses to MDT PowerShell: Connect to MDT Function

  1. davidjohnson529424291 says:

    you have an extra } in line 61

    Like

  2. Omar says:

    Hi Anderw,
    Is there a way to have the Windows 7 fully automated via WDS by combining MDT 2012? I would have never used MDT if WDS had a way to add Applications or Programs. Unfortunately, that capability is not available in WDS, so I got no choice but to combine WDS with MDT. Few days ago, I created a package in MDT, added the Lite-Touch PXE.wim file into WDS Boot group. Then I created an XML answer file which will do the fresh install of Windows 7 and then join it to the domain automatically, but Since I had a Lite-Touch boot file, it required my input and that I don’t want. I probably will have to customize bootstrap.ini file in MDT to achieve that target but I don’t know how I do it and I fear that customizing bootstrap.ini file may not work due to having same things in my unattended XML answer file in WDS. Can you please advise how do I go about achieving the fully automation without any conflict or problems?

    Thanks
    Omar

    Like

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