MDT PowerShell: New Module in MDT 2012

MDT-PowerShell-2012

Microsoft Deployment Toolkit 2012 now comes with a PowerShell module in addition to the PSSnapIn used in previous versions. In earlier versions of PowerShell in order to start using the PowerShell cmdlets for MDT you would have to add the snap-in by running this command:

Add-PSSnapIn Microsoft.BDD.PSSnapIn

Your scripts will still work with this method and it hasn’t been removed. But now the scripts are called by using a Module with this command:

Import-Module “C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1”

Using Get-Command –Module you can see that there are cmdlets for the new monitoring service.

image

I’m not sure that this module adds any value as the module would have worked better if deployed to the usual location of  C:\Windows\System32\WindowsPowerShell\v1.0\Modules so you wouldn’t need to type the entire path when calling it. You would also be able to discover it like in this example.

image

I guess I should have spoke up more during the beta testing but I was busy with my new baby. Sorry.

Posted in MDT 2012, Scripting | Tagged , , | 1 Comment

Microsoft Deployment Toolkit (MDT) 2012 RTM now available

Solution Accelerators

Today, Microsoft have released Microsoft Deployment Toolkit (MDT) 2012. I hosts a world of new features and improvements. My favourites are the ability to hide the GUI during deployments and the Validation check fix when deploying to Virtual Machines.

You can download it from the Microsoft Download Centre here.

What’s New in This Release?

  • Integration with Security Compliance Manager Templates
  • Run Windows PowerShell Scripts in Task Sequences
  • Automated Participation in CEIP and WER
  • Improved Guidance for Using SQL Server 2008 R2 with SP1
  • Support for Windows 8 Consumer Preview and Windows Server 8 Beta
  • Support for the Windows Assessment and Deployment Kit (Windows ADK).
  • Monitoring of LTI deployment process.
  • Deployment of Windows Recovery Environment (Windows RE).
  • Deployment of Microsoft Diagnostics and Recovery Toolkit (DaRT).
  • Deployment to computers that use the Unified Extensible Firmware Interface (UEFI).
  • Deployment to computers that require GUID Partition Table (GPT) format.
  • Deployment to virtual hard disks (VHDs) for native boot
  • Support for Windows Thin PC.
  • Support for Windows Embedded POSReady 7
  • Add local administrator accounts wizard step.
  • Deployment Wizard user experience improvements.
  • Support for System Center 2012 Configuration Manager.

What’s Been Removed from This Release?

  • Support for prerelease versions of Configuration Manager 2012
  • Support for installation of MDT on Windows Server 2003
  • Support for installation of MDT on Windows Vista
  • Support for installation of MDT on Windows XP
  • Support for Windows Deployment Services running on Windows Server 2003
  • Original equipment manufacturer task sequence templates from ZTI (Instead, use the prestaged media capabilities in Configuration Manager 2012 and Configuration Manager 2007 R3.)
Posted in Deployment, MDT 2012 | Tagged , , , | Leave a comment

MDT Scripting: Using VBScript Expressions in customsettings.ini file

I received an email from one of my readers:

I’m trying to deploy to a mixed physical / VM environment using the serial number for the OSDComputername. However, on my VMs (VM Ware) the VM serial number is full of spaces.  is there a way to stripe out the spaces on the fly?

Hi there, the answer is yes, there’s a number of ways to tackle this issue so I’ll walk through how I dealt with it.

To begin with, boot into WinPE and take a look at the problem itself, the serial number.

serialnumber

As you can see, it’s a messy one about 40 characters in length, it has leading text, spaces, 2 hyphen and although you can’t see it trailing spaces. VBScript has a number of ways to reformat strings.

If you’ve read my scripting articles you will know that you can get a copy of the MDT scripting template and add the following line to output an MDT variable to the console:

wscript.echo oEnvironment.Item("SerialNumber")

Your code should look like this example:


<job id="Z-Sample">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">

' //***************************************************************************
' // ***** Script Header *****
' //
' // Solution: Solution Accelerator for Microsoft Deployment
' // File: ZTIComputername.wsf
' //
' // Purpose: Testing MDT Variable Output
' //
' // Usage: cscript ZTIComputername.wsf [/debug:true]
' //
' // Script Version: 1.0.0
' // History:
' //
' // ***** End Header *****
' //***************************************************************************

'//----------------------------------------------------------------------------
'//
'// Global constant and variable declarations
'//
'//----------------------------------------------------------------------------

Option Explicit

Dim iRetVal

'//----------------------------------------------------------------------------
'// End declarations
'//----------------------------------------------------------------------------

'//----------------------------------------------------------------------------
'// Main routine
'//----------------------------------------------------------------------------

On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0

'//---------------------------------------------------------------------------
'//
'// Function: ZTIProcess()
'//
'// Input: None
'//
'// Return: Success - 0
'// Failure - non-zero
'//
'// Purpose: Perform main ZTI processing
'//
'//---------------------------------------------------------------------------
Function ZTIProcess()

iRetVal = Success

ZTIProcess = iRetval

     wscript.echo oEnvironment.Item("SerialNumber")

End Function

</script>
</job>

Save your script to the DeploymentShare\scripts folder and name it ZTIComputername.wsf. Next, boot your machine from your Lite-Touch media. Then in WinPE navigate to Z:\scripts and type:

cscript ZTIComputername.wsf

This is now the environment that we’ll customise the variable and test the results.

Echo serialnumber

Now we need to work on it.

To remove all spaces from a string

Ok, now you customise you script with this code below. This is a basic script that outputs both the old and new serial number. I’ve shown the whole function this time to demonstrate where to insert the code in the template.

Function ZTIProcess()
     iRetVal = Success
     ZTIProcess = iRetval

	wscript.echo vbCRLF & vbCRLF
	wscript.echo "Original SerialNumber: " & oEnvironment.Item("SerialNumber")
	wscript.echo vbCRLF & vbCRLF
	wscript.echo Replace(oEnvironment.Item("SerialNumber")," ","")
	wscript.echo vbCRLF & vbCRLF

End Function

Run the script again and this time the output looks like this:

Replace Spaces

For the next step. Let’s get rid of the hyphens by using the same method. You can simply wrap the existing code in the same method.

	wscript.echo Replace(Replace(oEnvironment.Item("SerialNumber")," ",""),"-","")

Replace Hyphens

Looking good, now let’s strip away the word ‘VMware’ at the start and select only 15 characters as 15 is the maximum allowed length.

  	wscript.echo Mid(Replace(Replace(oEnvironment.Item("SerialNumber")," ",""),"-",""),7,15)

Mid Text

Perfect. Now, the question is does that mean you have to write a vbscript to create the computername? No, you can use the expression you created above in the customsettings.ini enclosed in hashes. Here’s the finished solution(it’s a whopper).

OSDComputerName=#Mid(Replace(Replace(oEnvironment.Item("SerialNumber")," ",""),"-",""),7,15)#

Now in the deployment wizard, this is what you’ll see:

Results

There are many other ways of manipulating text in VB. There’s an MSDN manual here. You should be able to use these methods with other variables to tackle further issues.

Posted in MDT 2010, MDT 2012, Scripting | Tagged , , , | 1 Comment

TestLab: Network Design

When creating a test environment, one needs to spend some time pondering the design in order to avoid potential problems.

One past networking issue I had was getting the internet into my labs without bleeding DHCP from my servers into my home network. I solved it in the past by installing the Microsoft Loopback adapter on my guests but this was not ideal. This was especially so when I moved over to VMware workstation and also wanted to use my test laptops in my SCCM testing. Remember, even if your lab is only designed to test server computing, you will still need to learn and configure the basics of networking. My new design will take care of past issues for me. This is how it looks:

Home LAN

You’ll see from previous posts that I’ve purchased a HP Microserver and installed VMware ESXi 5. I’ve also installed an extra NIC. The plan is to have NIC 0 as a management network so I can manage ESXi from my laptop using PowerCLI and the VMware vSphere Client.

In order to achieve the above configuration, within VMware ESX 5 I’ve configured the networking like so:

Network

vSwitch0 is connected to my broadband router and home network. This will serve as a management network so I can WOL the host etc.

vSwitch1 is for guests and test machines only. It will talk to the internal LAN called collective.local and externally to the 2nd network card NIC 1. This will allow physical machines on my test network to receive DHCP and join the domain etc.

There will be 1 internal guest server (COL-Proxy01) that will have 2 network cards installed. Having 1 NIC in each network will allow it to act as a proxy server (Forefront TMG or Squid Virtual Appliance), bringing internet into the labs through vSwitch0 and serving it through vSwitch1. In future experiments I may later need to place COL-Proxy01 in the DMZ.

The end result now is that my test lab is completely isolated from my home network and I can manage and control my guest VM’s from the comfort of my laptop. I have the best of both worlds.

Posted in Testlab | Tagged , , , | Leave a comment

MDT 2010: Imaging to similar hardware

After a Sysprep operation, Hardware is detected and devices reinstall all their drivers. This behaviour is to by design and to be expected.

In many scenarios however, you may not want this to happen. For example, when you create a Virtual Machine template in VMWare or Hyper-V. In these situations the last thing you will want is to wait while Windows detects and installs all the drivers again each time you deploy the image. After all, you know that the hardware will always be the same.

To prevent this there is a setting you can configure in the Unattend.XML file. IT is called PersistentAllDeviceInstalls and it is found in the Microsoft-Windows-PnPSysprep path. I configure this setting when I create the reference image.

Lauch Windows SIM and locate the Microsoft-Windows-PnPSysprep component then right-click and select Add Setting to Pass 3 generalize.

2_thumb[3]

Next ensure the setting is set to True.

3_thumb[2]

Now when you clone a VM or redeploy an image you don’t have to wait that extra 5 minutes while the drivers are being detected and reinstalled.

Posted in MDT 2010 | Tagged , , , | Leave a comment

MDT 2010: Managing Answer Files

Microsoft Windows installation can be automated by the use of answer files. In previous editions, there was a Unattend.txt. These days the answer files are all xml based so you will need to author an Unattend.xml file.

MDT takes the headache out of this because it generates an answer file each time you create a new task sequence. You can customise this answer file using Windows System Image Manager

Windows System Image Manager (Windows SIM) creates and edits the Setup answer files. Each answer file is configured to a specific WIM image. Windows SIM will generate an index of the image into a catalog file with a .clg file extension. This shows what components exist in the associated wim file so you can configure the image specific settings. (Note: An x64 machine cannot generate an x86 catalog file.)

To make sense of Windows answer files, you will need an understanding of deployment Configuration Passes. Configuration Passes describe each of the phases that Windows takes when performing an installation. Not all passes are performed during a setup some Configuration Passes will only run after a Sysprep operation. You could also create an unattend.xml to configure the WindowsPE environment.

Configuration Passes

To edit an answer file

Right-Click the Task Sequence and select properties.

Start

Select the OS Info tab and click the Edit Unattend.xml button.

1

From there you are in Windows SIM and can edit the Unattend.xml file. Many settings in the file are overwritten by MDT during a deployment by using the propertys in the customsettings.ini. I would check to see if there is a setting first before making a change. I have blogged extensively on this topic here. Another great reference is the Unattended Windows Setup Reference on Technet.

Posted in MDT 2010 | Tagged , , , , , | Leave a comment

MDT 2012: Tip – Getting UUID, SerialNumber

I was working at a customers site last year creating a media based Windows 7 deployment for some laptops. I over heard one of the technical leads saying that he was deploying XP to a machine so he could use system information to collect the exact model from the machine. Naturally I offered him a quicker solution for which he was eternally grateful.

Boot into WinPE and type

     WMIC csproduct list /format

This will display the Make, Model and UUID in a formated list collected from WMI. You can use this tool in XP through to Windows 7 and on server editions also. You can find a list of commands using the WMI Command-line Tool tool here.

Posted in Deployment, MDT 2010, MDT 2012 | Tagged , , , , | 1 Comment