Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn a Windows feature on/off from the command line in Windows 10? [closed]

In Windows 10 and from "Programs and Features", you can turn Windows features on or off and then initiate a download and installation. I wish to turn ".NET Framework 3.5" ON and have it downloaded and installed, but I need to do it via e.g. a PowerShell script or via a command. I need to use the command line.

How can this be achieved?

Enter image description here

like image 747
fredrik Avatar asked Feb 18 '16 10:02

fredrik


People also ask

How do I turn Windows features on or off in Windows 10?

Here's how to turn on or off optional features on Windows 10 using Control Panel: Open Control Panel. Click on Programs. Click the Turn Windows features on or off link.

How do I turn Windows features on or off in PowerShell?

Enable or disable an optional feature You may use PowerShell commands to enable or disable optional features on a Windows 10 machine. The commands Enable-WindowsOptionalFeature -FeatureName and Disable-WindowsOptionalFeature -FeatureName are used for that.


2 Answers

Run a command prompt as an administrator and use:

dism /online /Get-Features

This will display the feature names since they don't always match up with what you're seeing in that visual feature list. It will also show which are currently enabled/disabled. Once you find the feature that you'd like to enable (NetFx3 in this case), run this:

dism /online /Enable-Feature /FeatureName:NetFx3

And as Richard stated, you can then disable a feature by simply switching "Enable" to "Disable" ex.

dism /online /Disable-Feature /FeatureName:NetFx3

Note: Sometimes a restart is required to see changes with windows features.

like image 56
Kyle Stoflet Avatar answered Oct 06 '22 01:10

Kyle Stoflet


To enable and disable features on a client machine of Windows using PowerShell, the cmdlet you have to use is:

Enable-WindowsOptionalFeature

For example, with Windows 10 and NetFX 3, I would check if the feature is enabled with

Get-WindowsOptionalFeature -Online | Where-Object -FilterScript {$_.featurename -Like "*netfx3*"}

If not enabled, run this to enable it:

Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -Source "SourcePath"
like image 27
Prasoon Karunan V Avatar answered Oct 06 '22 00:10

Prasoon Karunan V