posted 25/07/10

Automated boot image management in MDT 2010 and WDS using PowerShell

By Fredrik "DXter" Jonsson

One of my favorite features in MDT 2010 is that everything you do in the GUI is executing a PowerShell command that is using the cmd-let’s that comes with the MDT 2010 PowerShell snapin. Smile

 

This gives excellent opportunities for scripting geeks such as Dalle and myself since we can automate and do exactly everything what the GUI does, since the GUI itself is using PowerShell behind the scenes. Winking smile

 

This weekend I upgraded my private MDT environment to MDT 2010 Update 1 which was a very smooth operation. I have a very simple MDT environment at home with a single WDS/MDT server. Since I wanted to have the new and cool background picture in Windows PE that comes with Update 1, I had to update the boot images and import them to the WDS server, which in my case was on the same machine.

 

Therefore I created this little PowerShell script that does that for me automatically. The script is using the PowerShell cmd-let Update-MDTDeploymentShare and PS-Drive provider that comes with MDT 2010 snaping. It is also using wdsutil which is a command line based tool for managing WDS.

 

The script does the following tasks:

1. Generates completely new and updated boot images for your deployment share.

2. Removes you previous LiteTouch boot images from your WDS server.

3. Imports the newly created LiteTouch boot images into your WDS server.

4. Set each boot image as default boot image for respective architecture.

 

 

image

I must say, it works really nice. Smile

 

 

image

“Do more with less…” – the PowerShell way. Winking smile

 

The script is defaulting to MDT default names, descriptions and file locations. If you have changed any of this, please update the script according to your environment. Some people may ask why I choose to use Remove-Image and Add-Image and not Replace-Image. Well, the answer is quite simple. If I have deleted the boot image in WDS, the script would not be able to execute since there is no image to replace. If we split it up in to two commands, we will always be able to recreate our boot image in WDS regardless if the boot image is present or not, since only the Remove-Image command will fail and not the Add-Image.

 

So right now I have scheduled this script to run on my WDS/MDT server each midnight. If I add any new storage or NIC drivers into MDT, they will be injected automatically into the boot images during the next scheduled generation of boot images during the night and I “never” have to open the WDS console manually again! Open-mouthed smile

 

Here is the script (don’t forget to modify it according to your installation):

 

Add-PSSnapIn Microsoft.BDD.PSSnapIn

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

Update-MDTDeploymentShare -path "DS001:" -Force –Verbose

wdsutil /Remove-Image /Image:"Lite Touch Windows PE (x86)" /ImageType:Boot /Architecture:x86

wdsutil /Remove-Image /Image:"Lite Touch Windows PE (x64)" /ImageType:Boot /Architecture:x64

wdsutil /Verbose /Progress /Add-Image /ImageFile:C:\DeploymentShare\Boot\LiteTouchPE_x86.wim /ImageType:Boot

wdsutil /Verbose /Progress /Add-Image /ImageFile:C:\DeploymentShare\Boot\LiteTouchPE_x64.wim /ImageType:Boot

wdsutil /Verbose /Set-Server /BootImage:Boot\x86\images\LiteTouchPE_x86.wim /Architecture:x86

wdsutil /Verbose /Set-Server /BootImage:Boot\x64\images\LiteTouchPE_x64.wim /Architecture:x64

 

I must say, thank god for PowerShell! Red heart

 

// Fredrik “DXter” Jonsson

No Comments
read more
posted 24/01/10

Deployment Share Sorter

By Fredrik Wall

When working with MDT folders you want to sort
the folders by name to make It look better.

image

This is not a task you do in the Workbench.

I found a great script for this by Michael Niehaus
at Microsoft. It can be found here.

It will sort every folder in the Deployment Share structure.

image

The script will sort the structure by making a _TEMP_
folder and move the folder there and then move them
back sorted one by one.

You can do this manually as well in the Workbench
but It’s a big job then.

In my folder structure the comments will be deleted
this way.

image 

If I move (copy, paste, delete old folder) a folder
in the Workbench I will get the same result.

The property “Enable this folder” seems to work just fine
with moving folders.

Is this a known bug/feature?

I will write a script that fixes this for me later on next
week. Have to do another script first :)

 

Technorati Tags: ,,

1 Comment
read more
posted 24/01/10

Application folders in MDT 2010 + PowerShell

By Fredrik Wall

One nice thing with MDT 2010 is the possibility to
make folders in the Application folder.

I like a nice structure of things and with PowerShell
I can make my structure for MDT 2010 Applications,
Operating Systems and Drivers in no time.

image

cls
$MDTName = "MyMDT"
$MDTServer = "\\padc01"
$MDTApplications = "Antivirus", "Browser", "Office", "Twitter", "Security", "Server"
Add-PSSnapIn Microsoft.BDD.PSSnapIn
New-PSDrive -Name $MDTName -PSProvider MDTProvider -Root $MDTServer\DeploymentShare$
foreach ($MDTApp in $MDTApplications) {
    New-Item -path "$MDTName:\Applications" -enable "True" -Name "$MDTApp Applications"
 -Comments "$MDTApp Applications" -ItemType "folder" -Verbose -ErrorAction SilentlyContinue
}

9 lines of code can make 50 folders in 50 sec :)

And you can make it in less lines!

 

Technorati Tags: ,

3 Comments
read more
posted 23/01/10

Manage a remote MDT 2010 solution

By Fredrik Wall

This is a follow up on my last blog post about
using PowerShell from a Windows 7 machine
against a MDT 2010 solution (server).

It’s a how to use the Workbench on the
Windows 7 machine to manage a MDT 2010 solution
on a remote server.

image

First of all you need to go in to the Workbench
and the components section.

Then select Windows Automation Installation Kit x86 or x64
and download it by push the download button. It’s a large
file ~1 GB.

And when It is downloaded, select it again (it’s now under the downloaded section) and push the install button.

Now choose Open Deployment Share on the right side of the workbench.

The path should be like \\server\deploymentshare$

image

image

Now you got the same view on your Windows 7 machine
as on the MDT 2010 server.

image

I love this :)

But I don’t love the WAIK part, 1 GB of installation to be able to
do remote administration is not so good!

 

Technorati Tags: ,

4 Comments
read more
posted 23/01/10

MDT 2010 + PowerShell from Windows 7

By Fredrik Wall

I like to do everything from my Windows 7 machine.
One administration point with all of my scripts.

So I wanted to access my MDT 2010 server thru PowerShell
from It too.

As default this will not go.
You need to Add-PSSnapIn

Add-PSSnapIn Microsoft.BDD.PSSnapIn

And you will not have that on your Windows 7 machine

out of the box. But It’s not that hard to fix.

Just install MDT 2010 on the Windows 7 machine as well.

This is a 10 MB installation file only :)

No problem!

image

And now we can access our MDT solution remote with

PowerShell.

This is a small test script

cls
Add-PSSnapIn Microsoft.BDD.PSSnapIn
New-PSDrive -Name MyMDT -PSProvider MDTProvider -Root \\padc01\DeploymentShare$
cd MyMDT:
dir

And the output will be something like

WARNING: column "CurrentLocation" does not fit into the display and was removed.

Name           Used (GB)     Free (GB) Provider      Root                          
—-           ———     ——— ——–      —-                          
MyMDT                                  MDTProvider   \\padc01\DeploymentShare$     

Name : Applications

Name : Operating Systems

Name : Out-of-Box Drivers

Name : Packages

Name : Task Sequences

Name : Selection Profiles

Name : Linked Deployment Shares

Name : Media

 

4 Comments
read more
posted 23/01/10

First step with MDT 2010 and PowerShell

By Fredrik Wall

My very first step was to add the Microsoft.BDD.PSSnapIn.

Add-PSSnapin Microsoft.BDD.PSSnapin

 

And then I could make a new PSDrive

New-PSDrive -Name MyMDT -PSProvider MDTProvider -Root \\psdc01\DeploymentShare$

 

When I have a PSDrive I can access it thru

cd MyMDT:

dir

Name
—-
Applications
Operating Systems
Out-of-Box Drivers
Packages
Task Sequences
Selection Profiles
Linked Deployment Shares
Media

This means that I can access my MDT solution and do
everything with PowerShell. I’m in love! :)

But It will get better.
To learn much and fast about how to do tasks with PowerShell you can
use the MDT Workbench.

A simple and nice task is to create a folder for every Office application
that you want to add.

With the Workbench we do like this.

mdt-newfolder

mdt-newfolder2

mdt-newfolder3

On the last picture, on the right, just above finish
you got “View Script”.

This will open Notepad with a full .ps1 script
with the task that you did in the workbench.

image

This is nice!

Thanks DXter for the heads up on this.

More on MDT 2010 and PowerShell will come soon.

 

Technorati Tags: ,

3 Comments
read more
posted 10/09/09

MDT 2010

By Fredrik Wall

image

Microsoft Deployment Toolkit 2010 got released yesterday.
You will find the MDT 2010 site here.

Download it and start to deploy :)

 

No Comments
read more