Get-WindowsOptionalFeature and Enable-WindowsOptionalFeature in PowerShell

Run Get-WindowsOptionalFeature -Online in an elevated PowerShell to list every optional feature and its state, then use Enable-WindowsOptionalFeature -Online -FeatureName "Name" -All to turn one on and Disable-WindowsOptionalFeature -Online -FeatureName "Name" to turn it off. These DISM module cmdlets do the same job as the "Turn Windows features on or off" dialog, and they work on Windows 10 and 11.
This guide, first written for Windows 10 in 2017, covers listing features, reading details about one, and enabling or disabling it, plus how the same data looks through WMI.
List optional features and their state
Open PowerShell as administrator: tap the Windows-key, type powershell, hold Ctrl and Shift, and press Enter. Then run Get-WindowsOptionalFeature -Online. The -Online parameter means the command runs against the current device instead of an offline image. Microsoft documents this in the Get-WindowsOptionalFeature reference.

Each entry shows a FeatureName and a State such as Enabled or Disabled. The names are not always self-explanatory, and the list differs between editions and builds. To find a group of features, filter by name, for example Get-WindowsOptionalFeature -Online -FeatureName *Hyper-V*, or pipe the output to Format-Table FeatureName, State for a compact view.
The list below is from a Windows 10 Pro version 1809 system and is kept as a reference for the naming scheme. Your own system will show a different set, so run the command to see the current names.
- FeatureName : Printing-PrintToPDFServices-Features
- FeatureName : Windows-Defender-Default-Definitions
- FeatureName : Printing-XPSServices-Features
- FeatureName : SearchEngine-Client-Package
- FeatureName : MSRDC-Infrastructure
- FeatureName : TelnetClient
- FeatureName : TFTP
- FeatureName : TIFFIFilter
- FeatureName : WorkFolders-Client
- FeatureName : LegacyComponents
- FeatureName : DirectPlay
- FeatureName : Printing-Foundation-Features
- FeatureName : FaxServicesClientPackage
- FeatureName : Printing-Foundation-InternetPrinting-Client
- FeatureName : Printing-Foundation-LPDPrintService
- FeatureName : Printing-Foundation-LPRPortMonitor
- FeatureName : SimpleTCP
- FeatureName : MicrosoftWindowsPowerShellV2Root
- FeatureName : MicrosoftWindowsPowerShellV2
- FeatureName : Windows-Identity-Foundation
- FeatureName : Microsoft-Windows-Subsystem-Linux
- FeatureName : HypervisorPlatform
- FeatureName : VirtualMachinePlatform
- FeatureName : Client-ProjFS
- FeatureName : NetFx4-AdvSrvs
- FeatureName : NetFx4Extended-ASPNET45
- FeatureName : IIS-WebServerRole
- FeatureName : IIS-WebServer
- FeatureName : IIS-CommonHttpFeatures
- FeatureName : IIS-HttpErrors
- FeatureName : IIS-HttpRedirect
- FeatureName : IIS-ApplicationDevelopment
- FeatureName : IIS-NetFxExtensibility
- FeatureName : IIS-NetFxExtensibility45
- FeatureName : IIS-HealthAndDiagnostics
- FeatureName : IIS-HttpLogging
- FeatureName : IIS-LoggingLibraries
- FeatureName : IIS-RequestMonitor
- FeatureName : IIS-HttpTracing
- FeatureName : IIS-Security
- FeatureName : IIS-URLAuthorization
- FeatureName : IIS-RequestFiltering
- FeatureName : IIS-IPSecurity
- FeatureName : IIS-Performance
- FeatureName : IIS-HttpCompressionDynamic
- FeatureName : IIS-WebServerManagementTools
- FeatureName : IIS-ManagementScriptingTools
- FeatureName : IIS-IIS6ManagementCompatibility
- FeatureName : IIS-Metabase
- FeatureName : WAS-WindowsActivationService
- FeatureName : WAS-ProcessModel
- FeatureName : WAS-NetFxEnvironment
- FeatureName : WAS-ConfigurationAPI
- FeatureName : IIS-HostableWebCore
- FeatureName : IIS-StaticContent
- FeatureName : IIS-DefaultDocument
- FeatureName : IIS-DirectoryBrowsing
- FeatureName : IIS-WebDAV
- FeatureName : IIS-WebSockets
- FeatureName : IIS-ApplicationInit
- FeatureName : IIS-ASPNET
- FeatureName : IIS-ASPNET45
- FeatureName : IIS-ASP
- FeatureName : IIS-CGI
- FeatureName : IIS-ISAPIExtensions
- FeatureName : IIS-ISAPIFilter
- FeatureName : IIS-ServerSideIncludes
- FeatureName : IIS-CustomLogging
- FeatureName : IIS-BasicAuthentication
- FeatureName : IIS-HttpCompressionStatic
- FeatureName : IIS-ManagementConsole
- FeatureName : IIS-ManagementService
- FeatureName : IIS-WMICompatibility
- FeatureName : IIS-LegacyScripts
- FeatureName : IIS-LegacySnapIn
- FeatureName : IIS-FTPServer
- FeatureName : IIS-FTPSvc
- FeatureName : IIS-FTPExtensibility
- FeatureName : WCF-Services45
- FeatureName : WCF-HTTP-Activation45
- FeatureName : WCF-TCP-Activation45
- FeatureName : WCF-Pipe-Activation45
- FeatureName : WCF-MSMQ-Activation45
- FeatureName : WCF-TCP-PortSharing45
- FeatureName : MSMQ-Container
- FeatureName : MSMQ-Server
- FeatureName : MSMQ-Triggers
- FeatureName : MSMQ-ADIntegration
- FeatureName : MSMQ-HTTP
- FeatureName : MSMQ-Multicast
- FeatureName : MSMQ-DCOMProxy
- FeatureName : WCF-HTTP-Activation
- FeatureName : WCF-NonHTTP-Activation
- FeatureName : IIS-CertProvider
- FeatureName : IIS-WindowsAuthentication
- FeatureName : IIS-DigestAuthentication
- FeatureName : IIS-ClientCertificateMappingAuthentication
- FeatureName : IIS-IISCertificateMappingAuthentication
- FeatureName : IIS-ODBCLogging
- FeatureName : NetFx3
- FeatureName : SMB1Protocol
- FeatureName : SMB1Protocol-Client
- FeatureName : SMB1Protocol-Server
- FeatureName : SMB1Protocol-Deprecation
- FeatureName : MediaPlayback
- FeatureName : WindowsMediaPlayer
- FeatureName : Microsoft-Windows-NetFx3-OC-Package
- FeatureName : Microsoft-Windows-NetFx4-US-OC-Package
- FeatureName : Microsoft-Windows-Client-EmbeddedExp-Package
- FeatureName : Microsoft-Windows-NetFx3-WCF-OC-Package
- FeatureName : Microsoft-Windows-NetFx4-WCF-US-OC-Package
- FeatureName : Containers-DisposableClientVM
- FeatureName : Microsoft-Hyper-V-All
- FeatureName : Microsoft-Hyper-V
- FeatureName : Microsoft-Hyper-V-Tools-All
- FeatureName : Microsoft-Hyper-V-Management-PowerShell
- FeatureName : Microsoft-Hyper-V-Hypervisor
- FeatureName : Microsoft-Hyper-V-Services
- FeatureName : Microsoft-Hyper-V-Management-Clients
- FeatureName : HostGuardian
- FeatureName : Client-DeviceLockdown
- FeatureName : Client-EmbeddedShellLauncher
- FeatureName : Client-EmbeddedBootExp
- FeatureName : Client-EmbeddedLogon
- FeatureName : Client-KeyboardFilter
- FeatureName : Client-UnifiedWriteFilter
- FeatureName : DataCenterBridging
- FeatureName : DirectoryServices-ADAM-Client
- FeatureName : Windows-Defender-ApplicationGuard
- FeatureName : ServicesForNFS-ClientOnly
- FeatureName : ClientForNFS-Infrastructure
- FeatureName : NFS-Administration
- FeatureName : Containers
- FeatureName : SmbDirect
- FeatureName : MultiPoint-Connector
- FeatureName : MultiPoint-Connector-Services
- FeatureName : MultiPoint-Tools
- FeatureName : AppServerClient
- FeatureName : Internet-Explorer-Optional-amd64
Display information about one feature
Use the -FeatureName parameter to see details about a single feature: Get-WindowsOptionalFeature -Online -FeatureName NetFx3. In our original test this revealed that NetFx3 installs the .NET Framework 3.5, and the output includes a link to more information online. Feature names are case sensitive when servicing images older than Windows 8, so copy them exactly.

Enable or disable an optional feature
Use Enable-WindowsOptionalFeature to install a feature and Disable-WindowsOptionalFeature to turn it off, both with -Online and -FeatureName. Two examples:
- Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -All: installs the .NET Framework 3.5 on the computer the command runs on.
- Disable-WindowsOptionalFeature -Online -FeatureName "NetFx3": disables the feature again.
The -All parameter enables the parent features of the selected feature as well, so required dependencies are installed with it. The disable cmdlet has no -All parameter. Both cmdlets accept -NoRestart to suppress a reboot prompt, and several features can be passed as a comma-separated list. If the feature's files are not on the PC, Enable-WindowsOptionalFeature can fetch them from Windows Update, or from a folder you give with -Source (add -LimitAccess to skip Windows Update). Details are in Microsoft's Enable-WindowsOptionalFeature and Disable-WindowsOptionalFeature pages.
Check feature state through WMI
You can also read the same information from the Win32_OptionalFeature class: Get-CimInstance -ClassName Win32_OptionalFeature | Select-Object Name, InstallState. Microsoft's Win32_OptionalFeature page lists the InstallState values: 1 is enabled, 2 is disabled, 3 is absent and 4 is unknown. This is useful in scripts that only need to read state, while the DISM cmdlets above are the ones that change it.
Graphical alternative
The graphical route still exists: type optionalfeatures in Start to open the Windows Features window directly, as covered in our list of Windows tools, or open the Control Panel.
Related: Export Windows drivers with DISM, .NET Framework 4.8 offline installer, Manage Windows users with net user
Has any support been added for later versions of .Net, for example 4.6?
I see these options available when I use the GUI “Add Roles and Features Wizard” but they do not appear when I perform a “Get-WindowsOptionalFeature” listing.
Hello,
We are working on Windows 10 Entreprise deployment.
I see They so many features. is there any way to find which features to enable and which to disable en entreprise environnement (best practices)
Thank you
its on windows 8+
for oldest win :
dism /online /get-features
help and another command ( enable , disable, clear etc ) :
dism /online /?
Thanks a lot !
Eres un fucking maestro, no podÃa activar el DirectPlay de DirectX en Windows 10 (lite version) para jugar GTA San Andreas. Gracias a tu tutorial únicamente tuve que colocar en el PowerShell:
enable-windowsoptionalfeature -online -featurename “DirectPlay” -All
Mil gracias camarada! ;-)
https://technet.microsoft.com/en-us/library/dn482068.aspx
some programs that server 2008r2, 2012, 2012r2, 2012r2 essentials may need may need .net 3.5 so powershell needed to install
also anyone running exchange server 2013 (and I think 2010) uses exchange powershell a bunch
As Walter Matthau would say “Holy Moly”. If you think it doesn’t exist….it does. lol
You can start/stop dnscache manually via registry.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters
DWORD32 ‘Start’ 4 is enabled.
or via ‘net stop dnscache’.
This is only on your end, usually when ipconfig /flushdns cache is or was used it takes time for dnscache to resolve the list. Instead of using MS own DNSCache I highly recommend to use Unbound instead (unbound.net).
Both donot work with this build
Or you can install the ransomware yourself.
Wow, those are a lot of features. I’m guessing if I don’t know what they do I don’t need them?
Many of them are specialized features that you need only when you want to run or do certain things.
Martin w10 b16241build disabled the ability to stop/disable dnscache service.
Any news on why?
How can we disable it?
any powershell commands for permanently disabling it?
I have no information on that, but since this is a preview build, it could be a bug and not intended. Just checked and sc stop does not work on the command line.