Windows 8.1 has the .NET Framework 4.5.1 enabled by default. If you need .NET Framework 3.5 which also includes support for .NET 3.0, and 2.0, then you must enable the feature as it is not enabled by default.However to enable it you need access to the content of the Sources\SXS folder that resides on the Windows 8.1 installation media. More details are described in the MSDN article Installing the .NET Framework 3.5 on Windows 8 or 8.1
Follow the below instructions to enable the .NET Framework 3.5 within a ConfigMgr 2012 R2 task sequence.
On the ConfigMgr package source share create a new folder that acts as the package source folder for the .NET Framework 3.5 content and enabling script. Then copy the SXS folder located under the Sources folder on the original Windows 8.1 media into the new created folder. Next copy the enable-net35sp1.ps1 script into the same folder as well. (the content of enable-net35sp1.ps1 is listed below)
Within Configuration Manager create a new package called Windows 8.1 enable .NET Framework 3.5 sp1 with its data source path pointing to the previously created folder. The package does not need a program.
Next open the task sequence that is used to create the Windows 8.1 reference image and add a “Run PowerShell Script” task as shown in the example below.
- Package: Windows 8.1 enable .NET Framework 3.5 sp1
- Script Name: enable-net35sp1.ps1
As a result you should see the following when execution the task sequence.
The result, .NET Framework 3.5 enabled in Windows 8.1
Contents of the Enable-net35sp1.ps1 script.
<# .Synopsis Enables the .NET Framework Feature on Windows 8.1 .DESCRIPTION Enables the .NET Framework Feature on Windows 8.1 using a copy of the \sources\sxs folder content from the Windows 8.1 installation media .PARAMETER Source Optional parameter pointing to the location where the SXS files are located, if no -Source parameter is provided, the SXS folder is expected to be in the same folder as the script. .EXAMPLE Enable-NET35SP1.ps1 .EXAMPLE Enable-NET35SP1.ps1 -Source R:\Win81\Sources\sxs .LINK .NOTES Version 1.0, by Alex Verboon #> [CmdletBinding(SupportsShouldProcess=$true)] Param( [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, ParameterSetName="SXSPath", HelpMessage= 'SXS Folder')] [String]$Source ) Begin{ If ((Get-windowsoptionalfeature -FeatureName NetFx3 -Online | Select-Object -ExpandProperty State) -ne "Enabled") { Write-Verbose ".NET Framework 3.5SP1 is not enabled on this system" if ([string]::IsNullOrEmpty($Source)) { #No source path provided so set source path to SXS folder located in the script execution path # we'll check later if it actually exists $PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition $SxsSource = "$PSScriptRoot\SXS" } else { # set the Source to the provided path, we'll check later if it exists $SxsSource = $Source } } Else { Write-Output ".NET Framework 3.5 SP1 is already installed" Exit } } Process{ If ((Test-Path -Path "$SxsSource") -eq $false) { Write-Error "SXS Sources: SxsSource not found" } Else { Write-Verbose "SXS Sources: $SxsSource found" If ($PScmdlet.ShouldProcess("Enabling .NET Framework 3.5 Feature using Sources in $SxsSource","","")) { Write-Output "Enabling .NET Framework 3.5 Feature" enable-windowsoptionalfeature -featurename NetFx3 -Online -NoRestart -LimitAccess -All -Source $SxsSource -LogLevel WarningsInfo -ErrorAction Continue } } } End{ If ((Get-windowsoptionalfeature -FeatureName NetFx3 -Online | Select-Object -ExpandProperty State) -eq "Enabled") { Write-Output "Enabling .NET Framework 3.5 SP1 completed " } Else { Write-Output "Enabling .NET Framework 3.5 SP1 not completed" } }
Yeah this doesn’t work. Bombs out during the install step when it attempts the install from PS.
Fails to locate the PS script. Not sure in the steps above how you indicate the script name, but there is nowhere for the TS to reference it at. I understand creating the package and not creating a program for it. I also understand using the PS script to reference the folders within the sxs folder. However I don’t see how the TS will see the PS script.
HI Sammy,
Within the Task Sequence, Run PowerShell script properties you must reference the pacakge that you previously created. Let me know if that helps
I tried this example and got “zero”. No errors due to OSD process, no installed feature in the end. I wonder, what about power shell script execution policy? this script is unsigned, and does not run on any regular PC.
+ [CmdletBinding(SupportsShouldProcess=$true)]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected attribute ‘CmdletBinding’.
At J:\DotNet3.5\Enable-net35sp1.ps1:21 char:1
+ Param(
+ ~~~~~
Unexpected token ‘Param’ in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedAttribute
Any advice
If you get the “unexpected Attribute ‘CmdletBinding'” error, it’s because the comments in the code was translated in HTML (the brackets was translated into < and >)
I created a Package in ConfigMgr with no program containing the .NET 3 source, then selected to use it in a Command Line action in the State restore phase of an MDT generated TS, with the following command line;
DISM /online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:C:\_SMSTaskSequence\Packages\
I put this in the reference image I captured, so it’s not repeated for every image deployed.
Worked fine for me.
There is a variable for the package so you don’t have to use the hardcoded path on the source switch but I can’t remember it and I don’t have the TS to hand.
Hello,
I also tried to enable .NET Framework 3.5 during a SCCM 2012 R2 CU5 Task Sequence and if failed.
Well maybe the script it’s okay, I believe you can safely cut everything between <# and #> and leave just the script.
The real problem is here: http://nielsvdijk.blogspot.ro/2015/04/installing-net-framework-35-during-task.html
So basically, to enable .NET Framework, first you also need to remove/uninstall other 2 KBs:
KB2966826 – DISM /Online /Remove-Package /PackageName:Package_for_KB2966826~31bf3856ad364e35~amd64~~6.3.1.7 /quiet /norestart
KB2966828 – DISM /Online /Remove-Package /PackageName:Package_for_KB2966828~31bf3856ad364e35~amd64~~6.3.1.4 /quiet /norestart
After that you can enable/install .NET Framework using the script or the command:
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
The KBs can be installed afterwards:
KB2966828 – http://www.microsoft.com/en-us/download/details.aspx?id=43919
KB2966826 – http://www.microsoft.com/en-us/download/details.aspx?id=43926
Cheers.
aaaawwwwwwwwsome, it worked for Windows 2012 R2.
Following link didn’t helped me resolve the issue.
https://support.microsoft.com/en-in/help/3002547/you-cannot-enable-the-microsoft–net-framework-3-5-feature-on-windows