Home » PowerShell » PowerShell Get-WindowsOptionalFeature

PowerShell Get-WindowsOptionalFeature

Use the Get-WindowsOptionalFeature cmdlet in PowerShell to get information about all features including the optional features in the Windows image.

The Get-WindowsOptionalFeature is used to get a list of Windows optional features in the running operating system, retrieve a list of optional features in the package, and get details about features in a mounted image.

The Get-WindowsOptionalFeature syntax contains parameters that can be used to specify feature name, package name, online, package path, path, windows directory, and log level.

In this article, we will discuss how to use the Get-WindowsOptionalFeature cmdlet in PowerShell to get information about all features.

Cool Tip: The Get-WindowsOptionalFeature requires elevation. You must open the PowerShell terminal as “Run as administrator” to run the cmdlet.

What is the Syntax of Get-WindowsOptionalFeature

The syntax of Get-WindowsOptionalFeature is given below.

Get-WindowsOptionalFeature
   [-FeatureName <String>]
   [-PackageName <String>]
   [-PackagePath <String>]
   [-Online]
   -Path <String>
   [-WindowsDirectory <String>]
   [-SystemDrive <String>]
   [-LogPath <String>]
   [-ScratchDirectory <String>]
   [-LogLevel <LogLevel>]
   [<CommonParameters>]

Parameters used in the Get-WindowsOptionalFeature are given below.

-FeatureName: The name of a feature to get detailed information about it. Feature names are case-sensitive.

-PackageName: The name of the package as it is listed in the Windows image. Use the -PackageName parameter to get all the features in the package. You can use FeatureName and PackageName parameters to get more detailed information about a specific feature in the package.

-PackagePath: It specifies the name of the .cab file in the Windows image. Use this parameter to get all of the features in the package.

-Path: It specifies the full path to the root directory of the offline Windows image that you will service.

-Online: Use the Online parameter to specify the running operating system on your local computer.

-LogPath: It specifies the full path and file name to log to. If not set, then it uses the default path as %WINDIR%\Logs\Dism\dism.log.

-ScratchDirectory: It specifies the temporary directory that will be used while extracting files for use during servicing. The directory must exist locally. If it is not specified, it will use %Windows\%Temp%.

Let’s understand the PowerShell Get-WindowsOptionalFeature cmdlet in the DISM module with examples. In the below examples, we will use the command to get a list of features in a package and get details about a feature in a mounted image.

How to List Optional Features in the Running Operating System

Use the Get-WindowsOptionalFeature cmdlet in PowerShell to get a list of optional features in the operating system.

Get-WindowsOptionalFeature -Online

In the above PowerShell script, the command Get-WindowsOptionalFeature uses the parameter -Online to list all of the optional features in the running Windows operating system.

The output of the above command retrieves the list of all features and displays the FeatureName and State ( either Enabled or Disabled) for all of the features in the running operating system.

PowerShell - List Optional Features using Get-WindowsOptionalFeature
PowerShell – List Optional Features using Get-WindowsOptionalFeature

List Only Enabled Optional Features in the Running Operating System

Windows operating system contains either enabled or disabled optional features. You can get the list of enabled optional features in the running operating system using the filter to check if a state is enabled.

Get-WindowsOptionalFeature -Online | Where {$_.state -eq 'Enabled'} | Select FeatureName 

In the above PowerShell script, the Get-WindowsOptionalFeature cmdlet uses the -Online parameter to list all of the available features and sends it to the next command using the pipe operator.

The Where condition check if the state of the feature is equal to ‘Enabled‘ and select FeatureName.

The output of the above command displays the list of enabled optional features.

List Only Disabled Optional Features in the Running Operating System

You can retrieve the disabled optional features in the running operating system using the Get-WindowsOptionalFeatures with where condition to check if the feature state is disabled.

Get-WindowsOptionalFeature -Online | Where {$_.state -eq 'Disabled'} | Select FeatureName  

In the above PowerShell script, the Get-WindowsOptionalFeature command uses the parameter -Online to get a list of all optional features and uses the Where condition to check if the state is disabled, and displays the features name.

It displays the disabled optional features in the running operating system.

Get Details about a Feature in a Mounted Image

Use the Get-WindowsOptionalFeature cmdlet with parameters -Path and -FeatureName to get details about a feature in a mounted image.

Get-WindowsOptionalFeature –Path "D:\Win11" –FeatureName Hearts

In the above PowerShell script, the cmdlet Get-WindowsOptionalFeature uses the -Path parameter to specify the path to the root directory of the offline Windows image. It gets the details about a feature named Hearts in the mounted image.

Get Details about a Feature in a Specified Package in a Mounted Image

Get-WindowsOptionalFeature -Path "D:\Win11" -FeatureName "Hearts" -PackagePath "C:\packages\package.cab"

In the above PowerShell script, the Get-WindowsOptionalFeature uses the Path parameter to specify the path of the Windows image mounted to D:\Win11, it displays detailed information about the feature Hearts in the package at c:\packages\package.cab.

Cool Tip: How to install a telnet client using PowerShell and Cmd!

Get Details about Features using WildCard

You can use a wild card to specify the feature name in the command to get details about it.

Get-WindowsOptionalFeature -Online -FeatureName *Hyper-V*

In the above PowerShell script, the Get-WindowsOptionalFeature uses the -Online parameter to list all optional features and check for feature names *Hyper-V* in it.

It returns the details about the Hyper-V optional features in the running operating system.

The output of the above script to get details about the Hyper-v feature name is:

PS C:\> Get-WindowsOptionalFeature -Online -FeatureName *Hyper-V*                                                       

FeatureName      : Microsoft-Hyper-V-All
DisplayName      : Hyper-V
Description      : Provides services and management tools for creating and running virtual machines and their
                   resources.
RestartRequired  : Possible
State            : Disabled
CustomProperties :


FeatureName      : Microsoft-Hyper-V
DisplayName      : Hyper-V Platform
Description      : Provides the services that you can use to create and manage virtual machines and their resources.
RestartRequired  : Possible
State            : Disabled
CustomProperties :

You can use the Get-WindowsOptionalFeature cmdlet to check if hyper-v is enabled in the running operating system using PowerShell.

Get Windows Optional Features of Remote Computer

You can use the Invoke-Command cmdlet to get information about the optional features on a remote computer.

The following PowerShell script will get information about the optional features on the remote computer named ‘incorp-eu-101’

# Specify the remote computer name

$remoteComputerName = "incorp-eu-101"

# Get the list of optional features on remote computer

$features = Invoke-Command -ComputerName $remoteComputerName {Get-WindowsOptionalFeature -Online}

# Print the list of optional features
$features  

The above PowerShell script uses the Invoke-Command cmdlet to run the Get-WindowsOptionalFeature cmdlet on the remote computer retrieves the list of all optional features and stores it in variable $features. Finally, it prints the list of optional features to the console.

Get Windows Optional Feature RSAT Status on Windows OS

RSAT (Remote Server Administration Tools) can be installed on Windows 10/ Windows 11 or Windows Server systems. To check the RSAT status on the Windows operating system before its installation, run the following PowerShell script.

Get-WindowsOptionalFeature -Online -FeatureName *RSAT* | Select-Object FeatureName, state

In the above PowerShell script, the Get-WindowsOptionalFeature cmdlet gets the details about RSAT on the running operating system (Windows 10 here) and displays its feature name and state.

Get Windows Optional Feature Internet Explorer Status on Windows OS

You can use the Get-WindowsOptionalFeature cmdlet in PowerShell to get the feature name “Internet Explorer” details and its status on the Windows operating system.

Get-WindowsOptionalFeature -Online -FeatureName *Internet-Explorer* | Select-Object FeatureName,State

In the above PowerShell script, the Get-WindowsOptionalFeature command retrieves the details of the feature “Internet-Explorer” and displays its state as “Enabled” on the given Windows 10 operating system.

The output of the above PowerShell script is:

PS C:\> Get-WindowsOptionalFeature -Online -FeatureName *Internet-Explorer* | Select-Object FeatureName,State

FeatureName                        State
-----------                        -----
Internet-Explorer-Optional-amd64 Enabled

How to Check SMB1Protocol Status on Windows Operating System?

Use the Get-WindowsOptionalFeature cmdlet to get detailed information about the SMB1Protocol feature. It will get the SMB1Protocol feature name, display name, description, and status.

Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

In the above PowerShell script, the Get-WindowsOptionalFeature cmdlet uses the FeatureName parameter to specify the SMB1Protocol name and retrieve its properties.

The output of the above script displays the SMB1Protocol status as “Disabled” on the Windows 10 system ( running operating system).

PS C:\> Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol


FeatureName      : SMB1Protocol
DisplayName      : SMB 1.0/CIFS File Sharing Support
Description      : Support for the SMB 1.0/CIFS file sharing protocol, and the Computer Browser protocol.
RestartRequired  : Possible
State            : Disabled
CustomProperties :
                   ServerComponent\Description : Support for the SMB 1.0/CIFS file sharing protocol, and the Computer Browser protocol.
                   ServerComponent\DisplayName : SMB 1.0/CIFS File Sharing Support
                   ServerComponent\Id : 487
                   ServerComponent\Type : Feature
                   ServerComponent\UniqueName : FS-SMB1
                   ServerComponent\Deploys\Update\Name : SMB1Protocol

Conclusion

I hope the above article on the topic PowerShell Get-WindowsOptionalFeature to list all optional features is helpful to you.

We have learned how to use the cmdlet Get-WindowsOptionalFeature in PowerShell to list all optional features, get details about features in the running operating system, and a mounted image using different parameters.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.