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

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.

How to Use it

Step 1: Download it

Download it from here:

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" `

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

Download from

Step 4: Modify the Task Sequence

Open your task sequence and add the application like this:


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

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


Categories: MDT, OS Deployment, OSD, Reference Image

Tagged as: ,

13 replies »

  1. Is there a working sample of Install-NetFramework452.wsf anywhere? I am getting error “Unexpected Return Code 1”

    • The most common reason to get -1 is because the executable file is either not working or in the wrong folder. It simply means it cannot be found in the location where it should be. Open the script (that works perfectly fine) and you will see the path.

  2. Hi Michael,

    I am currently having big issues with deploying .net framework 3.5 on Server 2012 R2, after deployment, where WSUS does its work.
    A lot of people are struggling with this if you surf the internet forums.
    My dilemma is the following. If i install framework 3.5 in the reference image, as a pre-WU task as you have described, all servers will obviously have this installed.
    But is this a good idea? Does it create any issues for servers that do not need it?
    If i do not include installing 3.5 in the deployment, and want to install it after WSUS updates etc. it is a huge mess to get it installed, and that would be an understatement. People use hours and hours to troubleshoot errors installing 3.5 after WSUS (updates/patches for 4.5.*).

    I guess, i could maybe just make a whole new task sequence for 2012 R2 and call it “Server 2012 R2 with .net framework 3.5 incl.”?

    But what if people are not aware of the requirements (that DOES happen you know?! :D) and want it installed afterwards. What is the correct way of doing so.
    It seems that a lot of people have issues with mismatching SxS directory contents after WSUS has been running.

    Hope you can guide me here.

    Thank you.

    • Hi, a very good question. .NET is required by application, so if you don’t install applications on your servers, well den you don’t need it at all. Therefore you can divvied servers in two main classes, infrastructure servers and application servers. For Application servers you do need more or less all VC++ and all versions of .NET, for Infrastructure servers you don’t need anything. This would result in two images, you could then merge them into one WIM file and when you deploy them using MDT/ConfigMgr you could select the correct image. However, today most servers are virtualized and that would lead us into having two images. The question is then -Is that bad? What if I have only one that contains everything? Having just one image is easier to manage when it comes to deployment, however since that image no contains more software it also needs to be patched more frequently. So many of my customers have 3. A very thin Hyper-V ref image, a slightly thicker Infrastructure Image and an Application Image that contains the base platform for all the apps. The challenge with the .NET is that it is removed from the payload in the WIM file and there for it must be added, using WSUS basically never works for various reasons and therefor the only method is using DISM.
      When I create ref images I usually add a step to copy the SXS folder into the image, so if I ever need to add .NET if it was not added from the start, it is going to be in the C:\SXS folder. That way it is really easy. We used to that back in the old days for the i386 folder when we deployed Windows Server 2003

      • Hi Michael,
        Thank you for your switft reply. I still though, have issues with understanding the problem. Maybe i dont fully comprehend the concepts.
        People state that the problem is caused by WSUS right?
        So what i just tried, was deploying a VM from a windows stock image using WDS/MDT without applying ANY WSUS updates at all.
        When the deployment was done, i tried enabling .net framwork 3.5 through the server manager, firstly without pointing to the SxS folder, and then when that did not work, pointing to C:\windows\WinSxS.
        Why does this not work – this is a stock image without any tampering?

  3. The problem is that .NET framework 3.x is missing from the Wimfile, everything else is “inside”, but that is not the case, therefore those files needs to be added, the files are located on the media. The reason it works sometimes and sometimes not depends on various reasons (incorrect path, incorrect state, wrong WSUS server and more). So, the ONLY safe way to install it is using DISM using the path to the file. Trying to solve all the other issues, that is a dead end. The real problem is IMHO a bad choice, the solution is DISM + Path to SXS

    • I tried point to the medias SxS folder, using the dism command, in the above scenario, and it does not work. So I am once again totally confused here :)

    • The only thing working for me, is using the DISM command, pointing to an SxS folder, taken from an evaluation media, which is not the stock image we used to deploy the server. So that is weird.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.