Install the .NET Framework 3.5 in Windows 8 with a script (PowerShell)

Introduction

This Script demo shows how to install the .NET Framework 3.5 in Windows 8.

Scenarios

Many customers have to enable .NET Framework 3.5.

Script

This script contains one advanced function: Install-OSCNetFx3. You can use this script in the following ways:

Method 1:

  1. Download the script and open the script file together with Notepad or any other script     editor.
  2. Scroll down to the end of the script     file, and then add the example command which you want to run.
  3. Save the file then run the script in PowerShell.

Method 2:

1.    Rename scriptname.ps1 to scriptname.psm1 (PowerShell Module file)
2.    Run the following Import-Module cmdlet to import this module file.
        Import-Module filepath\scriptname.psm1

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

PowerShell
Edit|Remove
Write-Host "Installing .Net Framework 3.5, do not close this prompt..." 
                    DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:$LocalSource|Out-Null$Result = Dism /online /Get-featureinfo /featurename:NetFx3 
                    If($Result-contains "State : Enabled") 
                    { 
                        Write-Host "Install .Net Framework 3.5 successfully." 
                    } 
                    Else 
                    { 
                        Write-Host "Failed to install Install .Net Framework 3.5,please make sure the local source is correct." 
                    }

Examples

Example 1: Download the .NET Framework 3.5 online and then install it.
Command: Install-OSCNetFx3 -Online
Screenshot:

Example 2: Use a local source to install the .NET Framework 3.5.
Command: Install-OSCNetFx3 -LocalSource G:\sources\sxs
Screenshot:
 

Prerequisite

Windows 8

Additional Resources

Related forum thread:

http://social.technet.microsoft.com/Forums/en-US/w8itproinstall/thread/e764a507-81b6-4763-8ca8-9ad2f75b70ea/ 
http://social.technet.microsoft.com/Forums/en-US/W8ITProPreRel/thread/16215f3e-82da-4083-9b08-f2d231b7caf0/