The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • Archives

  • Meta

Archive for the ‘Reference Image’ Category

PowerShell is King – Building a Reference Image Factory (v 3.2)

Posted by Mikael Nystrom on February 23, 2017

The Image Factory has been re-worked and updated. It also has moved to GitHub https://github.com/DeploymentBunny/ImageFactoryV3ForHyper-V/

Concept and flow

The idea is the same, we use MDT, create refimages task sequences that runs without any questions. A PowerShell script will grab all enabled Task Sequences in a specified folder, create a VM for each of them. Grab the Bios Serial number from each om them, update customsettings ini with that information, start the VM’s (number of concurrent VM’s determine how many VM’s can run at the same time, wait until all VM’s are done and finally removes all VM’s for a cleanup process. You can run the script as is (if you store it in C:\Setup\ImageFactoryV3ForHyper-V on you MDT server), or you can open it in ISE and run section by section to see what happens.

The XML file (C:\Setup\ImageFactoryV3ForHyper-V\ImageFactoryV3.xml)

Is a control file for settings, pretty straightforward, just make sure that all values are correct.

image

The Script C:\Setup\ImageFactoryV3ForHyper-V\ImageFactoryV3-Build.ps1

The script contains some functions and logic, each section is described so you do know what it does. There are switches to the script,

  • -UpdateBootImage
  • -EnableMDTMonitoring
  • -TestMode

UppdateBoot image $True, updates the bootimage before copy, EnableMDTMonitoring require that MDT monitoring is enabled of the deployment share and testmode is not yet working (I’ll get back on that)

image

The PSINI Module

One big change is that instead of using a hack, (using KVP) I switched over to use a module called PSINI, it basically turns customsettings.ini into a hash table, making it easy to configure using PowerShell. That also means you need to download that module from TechNet Gallery http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91and all credit for that module goes to http://oliver.lipkau.net/blog

Have Fun

/Mike

Posted in MDT, PowerShell, Reference Image | Tagged: , , | 25 Comments »

OS Deployment – Adding a Wizard to control the Task Sequence behavior when you create a Reference Image

Posted by Mikael Nystrom on November 17, 2015

If you are in the business of doing Reference Imaging you want that process to be as automated as possible, but now and then you need to verify that different part of the task sequence works, lets say that you need to verify that an application you added to that task sequence get installed correctly, at time you don’t really like to run trough the entire Windows update process. Easy fix, you open the Task Sequence and disable it, but what if you could do some thing like this instead…A quick Note before you begin: This is not supported, since includes a modification a ZTIConfig.vbs and credit goes to Keith Garner for the explaining how to do that modification. Thanks!

I have done demos on this topic for some time now and I have promised to post this, so for all of you attending MMS in MN, TechDays and other various events, here you have it.

image

If that is what you want, here it is.

Adding the Suspend Step

The Suspend Step is a function that is built-in to MDT, but you need to add it. After you have done that the task sequence will suspend at that step and you can perform manual tasks, or test and verify that things works as expected. When you are done, just hit the “Resume Task Sequence” icon that will be on the desktop. Extremely useful, but instead of enable/disable by modifying the task sequence, it is nice to have that as checkbox.

Open your Task Sequence and browse to: State Restore \ Custom Tasks (My folder has been renamed to “Custom Tasks Post WU) and add a Run Command Line using the following settings:

  • Name: Suspend
  • Command Line: cscript.exe “%SCRIPTROOT%\LTISuspend.wsf”

image
The Suspend Step has been added.

Adding Conditions to the Steps.

We need a couple of Properties that we can use, let us use SuspendTS, DisableApps and DisableWSUS, add the following settings to the following steps in the Task Sequence.

For the Windows update steps, add the following Task Sequence Variable.

  • Variable: DisableWSUS
  • Condition: not equals
  • Value: NO

image
One of the Windows Update Step has the condition set, don’t forget to set them both.

For the Application install group steps, add the following Task Sequence Variable.

  • Variable: DisableApps
  • Condition: not equals
  • Value: NO

image
The group that install all the Applications has the correct condition set.

For the Suspend Task Sequence step, add the following Task Sequence Variable.

  • Variable: SuspendTS
  • Condition: equals
  • Value: YES

image
The Suspend Step Condition changed according to the list above.

Create an Application Bundle

We need a application bundle, the application bundle will actually not install anything at all, instead it is going to be the place holder for the HTML code. I recommend that you have all the “applications” you don’t want to see in a set of folders and this application in an other folder, or directly in the root, because this application should be seen, so you can “fill out the form”.

Create the Application Bundle using the following settings:

  • Application Type: Application Bundle
  • Application Name: Deployment Settings

image
The application Bundle has been created in the Config Folder.

Add HTML code to the Application Bundle

Open the Application Bundle and the the following HTML code to the comments field

<table>
<tr>
<td>Enable Suspend Task Sequence</td>
<td><INPUT type="checkbox" Name="SuspendTS" value="YES" /></td>
</tr>
<tr>
<td>Disable  Windows Update</td>
<td><INPUT type="checkbox" Name="DisableWSUS" value="NO" /></td>
</tr>
<tr>
<td>Disable Application Install</td>
<td><INPUT type="checkbox" Name="DisableApps" value="NO" /></td>
</tr>
</table>

Note:Make sure that your " are real " and not the “Word edition”

image
HTML has been added to the Comments filed.

Enable HTML code to run in the Comments field

Time for the unsupported part, the change you are about to do will stop the Wizard from parsing the comments field as text.

In scripts folder, find the file named ZTIConfig.vbs, make a copy of it, open the ZTIConfig.vbs and find the following line (around Line 700)

sComments = EncodeXML(oItem.SelectSingleNode("./Comments").Text)

and replace it with this

sComments = oItem.SelectSingleNode("./Comments").Text

Save the file.

Modify your CustomSettings.ini

We need to be able to select applications, so make sure your customsettings.ini shows:

  • SkipApplications=NO
  • SkipSummary=NO

The setting SkipSummery can later be set to YES, the setting I suggest is just so that you can see that Variables are set correctly with the need to run trough the entire deployment when testing this.

image
CustomSettings.ini has been modified.

Hide all other applications

When running the wizard, I don’t need to see all the applications, since the have been added to my task sequence. So you can either open each and every application and enable the “Hide this Application” checkbox, or you can (if you have all the applications in folders, just disable the folder.

image

Create Your Reference Image using the new “Wizard”

Boot the VM, select your Task Sequence and enable/disable the item.

Note: You don’t really need to select the application, it is just used as place holder for the HTML code, I have however made the application a default application to avoid confusion as a MnadatorApplications001={GUID}

image
All item have been Selected.

image
All values have been set correctly.

Have Fun!

/mike

Question: Do I need to select the application:
Answer: No

Question: Why don’t you add a Wizard Page instead?
Answer: Because that is more complicated if you don’t know exactly how the wizard works, this method is in most cases good enough and can be done even if you don’t have any experience in modifying the Wizard, you can as an example just add a dropdown box to be able to select certain items

Question: Do you have any other example on how to use this?
Answer: Yes, a ton of them

Question: If I don’t need to wizard thing anymore, how to I disable it?
Answer: Since it is an application, disable the application

Posted in MDT, OS Deployment, OSD, Reference Image, Unsupported | Tagged: , , , , | 6 Comments »

OS Deployment – VB Script Wrapper for all VC++ installers to be used in MDT/ConfigMgr

Posted by Mikael Nystrom on September 25, 2014

Update:

This scripts has been updated/modified:

– Installation of VC++ 2005 and 2015 has been removed

– Installation of VC++ 2017 has been added

The script has also been moved to GitHub

During todays session at The Ultimate Event I did a demo of a VBscript Wrapper that install all VC++ runtimes. Mr “Someone” asked if it was published and I said yes, I was wrong so here it is.

The Script

The script will install all versions of VC++ on 32 and 64 bit machines as an application in a task sequence, that way you don’t need to have one application for each VC++ application.

Download the script from here https://github.com/DeploymentBunny/Files/tree/master/Tools/Install-X86-X64-C%2B%2B

(it used to be on my Onedrive, now on Github)

The Task Sequence

After you have added the application in the MDT workbench, add the application to the Workbench like this:

image

The Application

When importing the application it should look like this:

image

The folder

The folder needs to have all the VC++ files organized in a folder structure that looks like this:

image
You can use the script in the following folder to download all files in the correct folder structure. Check this blog post:https://deploymentbunny.com/2014/08/05/powershell-is-king-download-all-vc-runtimes-using-a-script/

/mike

Posted in MDT, OS Deployment, OSD, Reference Image | Tagged: , , , | 25 Comments »

Back to Basic: .NET Framework 4.5.2 deployment in MDT using a VB Script wrapper

Posted by Mikael Nystrom on June 27, 2014

I got a tweet, it said “Why doing 4.5.1 when 4.5.2 is out”. So, this is just an update of the 4.5.1 post you can see here. https://deploymentbunny.com/2014/06/24/back-to-basic-net-framework-4-5-1-deployment-in-mdt-using-a-vb-script-wrapper/

How to Use it

Step 1: Download it

Download it from here: http://1drv.ms/TDbKJC

Step 2: Import it as an Application

Using the Deployment Workbench, import the application with the following options:

  • Application Type:
    • Application with source files
  • Details:
    • Application Name: Install – Microsoft .NET Framework 4.5.2
  • Source:
    • Source Directory: The location where you unzipped the files
  • Destination:
    • Directory Name: Install – Microsoft .NET Framework 4.5.2
  • Command Details:
    • Command Line: cscript.exe Install-NetFramework452.wsf

If you prefer PowerShell to import the application, here is an example POSH Snippet:

Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"

New-PSDrive -Name "DS001" `
-PSProvider MDTProvider `
-Root "E:\MDTBuildLab"

import-MDTApplication `
-path "DS001:\Applications\Install" `
-enable "True" `
-Name "Install – Microsoft .NET Framework 4.5.2" `
-ShortName "Install – Microsoft .NET Framework 4.5.2" -Version "" `
-Publisher "" `
-Language "" `
-CommandLine "cscript.exe Install-NetFramework452.wsf" `
-WorkingDirectory ".\Applications\Install – Microsoft .NET Framework 4.5.2" `
-ApplicationSourcePath "C:\Users\Administrator\Desktop\Install – Microsoft .NET Framework 4.5.2" `
-DestinationFolder "Install – Microsoft .NET Framework 4.5.2" `
-Verbose

Step 3: Download .NET framework 4.5.2 exe file and save it in the Application\Source folder

Download from http://www.microsoft.com/en-us/download/details.aspx?id=42642

Step 4: Modify the Task Sequence

Open your task sequence and add the application like this:

image

Sample of a Windows 7 task sequence with .NET Framework 4.5.2

image
Sample of a Windows 8.1 task sequence with .NET Framework 4.5.2

Note: You might need to add a reboot before and one after, since .Net Framework might feel better, my sequence does not need it, but yours might depending on what you add before this.

Note: For Windows 8/8.1 (Server 2012/2012 R2) I always add .NET 2/3 as Roles BEFORE adding 4.5.2, just to make sure nothing is messed up.

Step 5: Create your Ref Image

/mike

Posted in MDT, OS Deployment, OSD, Reference Image | Tagged: , | 13 Comments »

Back to Basic: .NET Framework 4.5.1 deployment in MDT using a VB Script wrapper

Posted by Mikael Nystrom on June 24, 2014

Yesterday an OS Deployment friend (you know who you are…) asked around for a way to install .NET Framework 4.5.1 as a part of the reference image creation and I told him I would post it today, so here it is. The reason I do this with VB script wrappers (not only me, most of the people I know and works with OSD does that) is logging and full control, but also the fact that I have a bunch of VBscripts that are very similar and the fact that MDT has a very nice module called ZTIUtility that connects external scripts built in functions make this a very easy choice.

Hey, you might need 4.5.2 instead? –> https://deploymentbunny.com/2014/06/27/back-to-basic-net-framework-4-5-2-deployment-in-mdt-using-a-vb-script-wrapper/

How to Use it

Step 1: Download it

Download it from here: http://1drv.ms/TqAqVD

Step 2: Import it as an Application

Using the Deployment Workbench, import the application with the following options:

  • Application Type:
    • Application with source files
  • Details:
    • Application Name: Install – Microsoft .NET Framework 4.5.1
  • Source:
    • Source Directory: The location where you unzipped the files
  • Destination:
    • Directory Name: Install – Microsoft .NET Framework 4.5.1
  • Command Details:
    • Command Line: cscript.exe Install-NetFramework451.wsf

If you prefer PowerShell to import the application, here is an example POSH Snippet:

Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"

New-PSDrive -Name "DS001" `
-PSProvider MDTProvider `
-Root "E:\MDTBuildLab"

import-MDTApplication `
-path "DS001:\Applications\Install" `
-enable "True" `
-Name "Install – Microsoft .NET Framework 4.5.1" `
-ShortName "Install – Microsoft .NET Framework 4.5.1" -Version "" `
-Publisher "" `
-Language "" `
-CommandLine "cscript.exe Install-NetFramework451.wsf" `
-WorkingDirectory ".\Applications\Install – Microsoft .NET Framework 4.5.1" `
-ApplicationSourcePath "C:\Users\Administrator\Desktop\Install – Microsoft .NET Framework 4.5.1" `
-DestinationFolder "Install – Microsoft .NET Framework 4.5.1" `
-Verbose

Step 3: Download .NET framework 4.5.1 exe file and save it in the Application\Source folder

Download from http://www.microsoft.com/en-us/download/details.aspx?id=40779

Step 4: Modify the Task Sequence

Open your task sequence and add the application like this:

image

Sample of a Windows 7 task sequence with .NET Framework 4.5.1

image
Sample of a Windows 8.1 task sequence with .NET Framework 4.5.1

Note: You might need to add a reboot before and one after, since .Net Framework might feel better, my sequence does not need it, but yours might depending on what you add before this.

Note: For Windows 8/8.1 (Server 2012/2012 R2) I always add .NET 2/3 as Roles BEFORE adding 4.5.1, just to make sure nothing is messed up.

Step 5: Create your Ref Image

/mike

Posted in MDT, OS Deployment, OSD, Reference Image | Tagged: , | 7 Comments »