This Script demo shows how to install the .NET Framework 3.5 in Windows 8.
Many customers have to enable .NET Framework 3.5.
This script contains one advanced function: Install-OSCNetFx3. You can use this script in the following ways:
Method 1:
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.
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."
}
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." }
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:
Windows 8
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/