Tuesday, 05 September 2017 12:08

Add .NET Framework Offline Using MDT

Written by
Rate this item
(2 votes)


If you’ve read any of my tweets, you know that I emphasize how Microsoft Deployment Toolkit and ConfigMgr are powerful OS deployment tools which allow a high grade of customization. This blog post is another demonstration of MDT flexibility. It also shows how a small PowerShell script can quickly lead to a solution.

Assume following scenario:

  • You install Windows 10 using unmodified Microsoft Windows 10 image using either MDT or ConfigMgr
  • You install .NET Framework 3.5 during State Restore phase

Note: Windows 10 comes with .NET framework 4.x pre-installed, but many applications developed a couple of years ago still require the .NET framework v3.5 installed along with 4.5. Windows 10 will prompt you to install .NET framework 3.5 when you try to run any such app.

The case opened when a customer contacted me because during Windows 10 OSD testing they encountered the Install Windows Features dialogue appearing right after the first auto logon prior to task sequence resuming after OOBE.

I verified the issue, checked Windows 10 task sequence, but could not find anything that would explain the problem: .NET Framework 3.5 was supposed to get installed via task sequence after the first auto logon. However, the "Windows Feature" pop up appeared before the task sequence could kick in. Next, I started looking for a common denominator: the issue reared its ugly head only on a HP EliteBook X2 1012 G1 convertible. Additionally, I remembered that a couple of days ago we updated all MDT driver packages using the MDT driver automation script I described in one of my earlier blog posts, which led to me to the conclusion that a recently added HP driver package was dependant on .NET Framework 3.5 causing the "Windows Feature" installation dialogue to show up.

My goal now was to determine a workaround which would allow the customer to use HP driver packages without any modifications. I had to somehow inject .NET Framework 3.5 into the OS before OOBE. The way that immediately jumped to mind as the easiest was to create a reference image - sadly, that was not option here, so I turned my attention to DISM. DISM (Deployment Image Servicing and Management) is a command-line tool that can be used to service and prepare Windows images, including those used for Windows PE, Windows Recovery Environment (Windows RE) and Windows Setup. You can use DISM to add .NET Framework 3.5 offline to an installation of Windows 10 as long as you provide access to the %DEPLOYROOT%\Operating Systems\%Windows10_1709_folder%\sources\SxS folder in the deployment share.

I wrote a small PowerShell script that would install .NET Framework 3.5 during the Post Install TS phase in Windows PE, added it to my MDT task sequence and - positive I'd solved my issue - ran the task sequence. To my immense satisfaction the pop up did not show up. Case closed! As for why the "Windows Feature" installation dialogue started showing after a driver package update, with everything else on my plate I haven’t had the time to investigate further.

How does it work:

Should you end up in the same boat, follow these steps to work around the problem:

  1. Add this script to your MDT deployment share:
    # Determine where to do the logging 
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 
    $logPath = $tsenv.Value("LogPath")  
    $logFile = "$logPath\$($myInvocation.MyCommand).log"
    # Create Logfile
    Write-Output "Create Logfile" > $logFile
    Function Logit($TextBlock1){
    	$TimeDate = Get-Date
    	$OutPut = "$ScriptName - $Section - $TextBlock1 - $TimeDate"
    	Write-Output $OutPut >> $logFile
    # Start Main Code Here
    $ScriptName = $MyInvocation.MyCommand
    # Get data
    $Section = "Initialization"
    $OSDisk = $tsenv.Value("OSDisk")
    $ScratchDir = $tsenv.Value("OSDisk") + "\Windows\temp"
    $NetFxSource = $tsenv.Value("SourcePath") + "\sources\sxs"
    $RunningFromFolder = $MyInvocation.MyCommand.Path | Split-Path -Parent 
    . Logit "Running from $RunningFromFolder"
    . Logit "Property OSDisk is now $OSDisk"
    . Logit "Property ScratchDir is now $ScratchDir"
    . Logit "Property NetFxSource is now $NetFxSource"
    $Section = "Installation"
    . Logit "Adding .NET Framework 3.5...."
    dism.exe /Image:$OSDisk /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:$NetFxSource /ScratchDir:$ScratchDir
    Make sure that WindowsSource variable is configured in your CustomSettings.ini. Example:
    ;NetFX 3.5 source path 
    WindowsSource=%DeployRoot%\Operating Systems\Windows 10 Enterprise 1709 x64\sources\sxs
  2. Add the PowerShell script to your Windows 10 task sequence.

That's it!

Read 26639 times Last modified on Saturday, 16 September 2017 00:26

Recent Posts

  • Windows 10 21H2 Built-In Apps: What to Keep
    The development of the Windows 10, version 21H2 is finished and the update will soon be available for download from…
    Written on Wednesday, 20 October 2021 11:41
  • Group Policy Changes in Windows 10 21H2
    As Windows 10, version 21H2 update development winds down, Microsoft is now preparing for the final release of the Windows…
    Written on Wednesday, 20 October 2021 07:20
  • Group Policy Changes in Windows 10 20H1 Preview
    As Windows 10 Vibranium Update (20H1) development winds down, Microsoft is now beginning the phase of checking in the final…
    Written on Tuesday, 14 January 2020 04:51
  • An alternative ESU MAK Activation Solution
    This blog post was shared with me by a colleague of mine, Daniel Dorner, a Microsoft Premier Field Engineer. It’s…
    Written on Wednesday, 04 December 2019 21:04
  • The Case of Missing UE-V Templates
    My customers often deal with unexpected Windows behavior and this case is no different. This particular one is especially interesting…
    Written on Tuesday, 03 September 2019 12:20
  • The Case of Changing Default Printer
    While I sometimes long for the day when I no longer have to deal with unexpected Windows 10 behavior, there’s…
    Written on Wednesday, 14 August 2019 20:36