Tuesday, November 6, 2012

Installing .NET 3.5 on Windows10/8/Server 2012 With Powershell

Here's how to install .NET 3.5 (or another feature by subbing the feature name) on Windows 8/10 or Server 2012 from Powershell:
  • Launch Powershell as Admin
Install .NET 3.5 using default sources (Windows Update or defined in group policy)
  • 2012: Install-WindowsFeature –name NET-Framework-Core
  • Win8/10: Enable-WindowsOptionalFeature –Online –FeatureName NetFx3 –All
Install .NET 3.5 using a network SxS share: 
  • 2012: Install-WindowsFeature –name NET-Framework-Core -source \\server\share\source\sxs
  • Win8/10:Enable-WindowsOptionalFeature –Online –FeatureName NetFx3 –All -LimitAccess -Source \\server\share\source\sxs
    • On Windows 8, -all indicates that all parent features should be enabled as well and -LimitAccess prevents it from connecting to Windows Update. These options are not valid on Win 2012. 
Install .NET 3.5 using DVD-ROM 
  • 2012: Install-WindowsFeature –name NET-Framework-Core -source j:\sources\sxs    (See note below)
  • Win8:Enable-WindowsOptionalFeature –Online –FeatureName NetFx3 –All -LimitAccess -Source J:\sources\sxs
Make sure to run Windows Update after install if you're installing from a non-updated source!

Note: Depending on your configuration, on server 2012 you may need to use the install.wim on the install media and specify the index of the proper version of your install. To do so, execute:

Get-WindowsImage -ImagePath {OpticalDrive}:\sources\install.wim
This will display a list of images with associated indexes. Take note of the index of your install type.
Then, instead of the -source line above, use -source:wim:e:\sources\install.wim:X (where X is the number of the appropriate index. 

Update: Confirmed this works on Windows 10 as well!


Unknown said...

I had to remove the "-name" in my install for 2012

Install-WindowsFeature NET-Framework-Core -source \\server\share\source\sxs

Toby Meyer said...

Hey Phillip!

Perhaps you had a spacing issue; I confirmed that (at least for me) it does work either way, which makes sense as it looks to be the default option. Per the get-help,

Specifies a list of features to install. This parameter does not support wildcard characters. If this
parameter is specified, then the ConfigurationFilePath parameter cannot be used.

Required? true
Position? 1
Default value
Accept pipeline input? True (ByValue)
Accept wildcard characters? false

Specifying -name is optional for this command, but I like to include all option names in my posts to illustrate what the option is. (for better context) Thanks!

Unknown said...

Windows 8.1. This worked for me. It didn't like a mapped drive.

Enable-WindowsOptionalFeature –Online –FeatureName NetFx3 –All -LimitAccess -Source \\NAS\Software\Microsoft\SxS_Win81

Unknown said...

When I start to do as you said I've receive a crash message with losting one of dll files in my system folder. So I tried to search them immidiately, to return everything as it was. I found the site where it is possible to download the vcruntime140.dll missing https://fix4dll.com/vcruntime140_dll. Most likely they will be needed by everyone who decided to install a new software such a truly useful resource always at hand. At least as for me, for sure. Maybe nobody here, do not got such bug...