Powershell get windows feature

As a system administrator, I was required to list Windows features using PowerShell. In this tutorial, I will explain how to list Windows features using PowerShell.

Let me show you how to do this.

Note: Open PowerShell with administrative privileges by right-clicking the PowerShell icon and selecting “Run as Administrator.

Listing Windows Features with Get-WindowsFeature

The Get-WindowsFeature cmdlet is the primary cmdlet for listing Windows features. It provides a detailed view of all roles, role services, and features available on the server.

To list all Windows features, open PowerShell and run the following command:

Get-WindowsFeature

This command will display a comprehensive list of all available and installed features on your Windows server. Each feature is listed with its display name, name, and installation status.

Filter Results

You can filter the results to show only installed features by using the -Installed parameter:

Get-WindowsFeature -Installed

This command will list only the features that are currently installed on your server.

Example: Listing Features on a Remote Server

If you need to list features on a remote server, use the -ComputerName parameter followed by the server name or IP address:

Get-WindowsFeature -ComputerName "Server01"

Replace “Server01” with the name or IP address of your remote server. Ensure you have the necessary permissions to access and manage the remote server.

Example: Filter by Feature Name

To filter the results by a specific feature name, use the -Name parameter like below:

Get-WindowsFeature -Name "Web-Server"

This command will display information about the “Web-Server” feature, including its installation status and dependencies.

Display Subfeatures using Get-WindowsFeature

Some features have subfeatures that can be installed or removed independently. To display these subfeatures, use the -IncludeSubFeature parameter:

Get-WindowsFeature -Name "Web-Server" -IncludeSubFeature

This command will list the “Web-Server” feature along with all its subfeatures.

Export Results to a File

You can export the list of Windows features to a file for further analysis or documentation purposes. Use the Export-Csv cmdlet to export the results to a CSV file:

Get-WindowsFeature | Export-Csv -Path "C:\WindowsFeatures.csv" -NoTypeInformation

This command will save the list of Windows features to a CSV file named “WindowsFeatures.csv” in the C: drive.

Check out Check for Windows Updates Using PowerShell

Examples

Now, let me show you some examples.

Scenario 1: Preparing a New Server

Imagine you’re setting up a new server for a web application in New York. You need to ensure that all necessary features are installed. First, you list all installed features to get an overview:

Get-WindowsFeature -Installed

Next, you identify the required features for your web application, such as the Web Server (IIS) role:

Get-WindowsFeature -Name "Web-Server"

If the Web Server role is not installed, you can install it using the Install-WindowsFeature cmdlet:

Install-WindowsFeature -Name "Web-Server"

Scenario 2: Auditing Server Configuration

As part of a security audit in a San Francisco data center, you need to document the features installed on several servers. You can automate this task using PowerShell:

$servers = @("Server01", "Server02", "Server03")
foreach ($server in $servers) {
    Get-WindowsFeature -ComputerName $server | Export-Csv -Path "C:\$server-WindowsFeatures.csv" -NoTypeInformation
}

This script will list the features on each server and save the results to a CSV file.

Check out Install Windows Updates Using PowerShell

Troubleshooting Common Issues

Here are some common issues that you might face while working with these commands.

Issue 1: Access Denied

If you encounter an “Access Denied” error, ensure you are running PowerShell with administrative privileges. Right-click the PowerShell icon and select “Run as Administrator.”

Issue 2: Remote Server Connectivity

If you cannot connect to a remote server, verify the following:

  • Network connectivity between your local machine and the remote server.
  • Remote management is enabled on the remote server.
  • You have the necessary permissions to access and manage the remote server.

Issue 3: Feature Not Found

If a specific feature is not listed, it may not be available on your version of Windows. Check the official Microsoft documentation for a list of features available on your Windows version.

In this tutorial, I have explained how to list Windows Features Using PowerShell with the Get-WindowsFeature cmdlet.

You may also like:

  • Install .NET Framework 3.5 Using PowerShell
  • Get Windows Update History Using PowerShell
  • Install RSAT in Windows 11 Using PowerShell

Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.

Overview

Get-WindowsFeature enables you to retrieve and manage Windows features, which are optional software components that can be installed or removed to customize the functionality of Windows systems. It provides detailed information about installed and available features, allowing you to assess system capabilities and make informed decisions about feature management.

Syntax

Get-WindowsFeature [-Name] <string[]> [-Prefix <string>] [-Required <boolean>] [-Optional <boolean>] [-Installed <boolean>]
                      [-Available <boolean>] [-ComputerName <string>] [-Detailed] [-Wildcards <boolean>]

Options/Flags

  • -Name: Specifies the exact name(s) of the Windows feature(s) you want to retrieve information about.
  • -Prefix: Filters features based on a prefix within the feature name.
  • -Required: Specifies whether to include only required features in the results.
  • -Optional: Specifies whether to include only optional features in the results.
  • -Installed: Specifies whether to include only installed features in the results.
  • -Available: Specifies whether to include only features available for installation in the results.
  • -ComputerName: Specifies the remote computer from which you want to retrieve feature information.
  • -Detailed: Displays additional information about each feature, including description, display name, and installation state.
  • -Wildcards: Allows the use of wildcard characters (*) in feature names for wildcard matching.

Examples

Example 1: Get Installed Features

Get-WindowsFeature -Installed

Example 2: Find Features Containing “Hyper”

Get-WindowsFeature -Prefix Hyper

Example 3: Get Detailed Information About Specific Features

Get-WindowsFeature -Name .NETFramework-Core-WindowsDesktop, Hyper-V -Detailed

Common Issues

  • Error fetching remote features: Verify that you have administrative privileges and that Windows Remote Management (WinRM) is enabled on the remote computer.
  • Incorrect feature name: Confirm that you have specified the correct feature name. Use Get-WindowsFeature -Available to view available features.
  • Unavailable features: Some features may not be available for installation on your system due to hardware or software limitations.

Integration

Get-WindowsFeature can be integrated with other PowerShell commands for advanced tasks:

  • Install-WindowsFeature: Use the results from Get-WindowsFeature to target specific features for installation.
  • Uninstall-WindowsFeature: Remove installed features using the names retrieved with Get-WindowsFeature.
  • Get-WindowsOptionalFeature: Retrieve information about optional features using a similar syntax.
  • Enable-WindowsOptionalFeature: Enable optional Windows features.
  • Microsoft Docs: Get-WindowsFeature
  • Microsoft Docs: Windows Feature Management

In this article, I will demonstrate how to get Windows features using PowerShell on servers. The Get-WindowsFeature cmdlet lists all the roles and Windows features installed on a server.

If you are asked to find the features installed on a specific server, you can use PowerShell to complete the task. Manually listing down the installed features will take time, and you cannot do this when you have multiple servers in the setup.

There are many ways to locate the installed features on the server, including Configuration Manager and third-party tools. However, PowerShell is the most straightforward and cost-free way to discover what features are installed on Windows servers.

Install and Update Third Party Applications with Patch My PC

Install and Update Third Party Applications with Patch My PC

About Get-WindowsFeature Cmdlet

The Get-WindowsFeature cmdlet gets information about features that are both available for installation and already installed on a computer that is running Windows Server or an offline virtual hard disk (VHD) that is running Windows Server.

Clearly, Windows features and roles are only available on server operating systems and not on client operating systems. Therefore, the Get-WindowsFeature cmdlet can only be executed on Server Operating Systems.

You can specify the following parameters along with the Get-WindowsFeature cmdlet.

  • -Name
  • -Vhd
  • -ComputerName
  • -Credential
  • -LogPath

How to Get Windows Features using PowerShell

Let’s go through some examples of using the Get-WindowsFeature cmdlet to get Windows roles and features using PowerShell.

List all the Windows Features on Server

Run the below PowerShell command to list all the features that are available and installed on the Windows Server.

Get-WindowsFeature

In the command output, a summary of all installed and available features for installation on the server is displayed. The display name column displays the Windows feature’s name, while the “Install State” column indicates whether a feature is installed or available.

Get Windows Features using PowerShell

Get Windows Features using PowerShell

Find All Installed Features on Windows Server

If you want to find out the features that are installed on a given Windows Server, run the following command in the PowerShell window.

Get-WindowsFeature | where{$_.InstallState -eq "Installed"}

In the screenshot below, we see the PowerShell command output shows all the Windows features installed on the server.

Find All Installed Features on Windows Server

Find All Installed Features on Windows Server

List all Windows Features that are not Installed

To list the Windows features that are not installed on a server, you can use the below PowerShell command.

Get-WindowsFeature | where{!($_.InstallState -eq "Installed")}
List all Windows Features that are not Installed

List all Windows Features that are not Installed

Get Installed Windows Features using Name or Wildcard

If you need to find a specific feature installed on the server, simply input the Name or Display Name. If you don’t know the whole name of the feature/role, you can use the wildcard character to find the features.

For example, on a Windows Server, if you want to find the installed features that begin with “Cert“, you can use the following command.

 Get-WindowsFeature *Cert*

The below command output shows all the Windows Features whose name begins with Cert.

[X] Active Directory Certificate Services               AD-Certificate                 Installed
    [X] Certification Authority                         ADCS-Cert-Authority            Installed
    [ ] Online Responder                                ADCS-Online-Cert               Available
            [ ] Centralized SSL Certificate Support     Web-CertProvider               Available
            [ ] IIS Client Certificate Mapping Authe... Web-Cert-Auth                  Available
List Installed Windows Features using Name or Wildcard

List Installed Windows Features using Name or Wildcard

Find Installed Features on Remote Windows Server

If you want to list the Windows features installed on a remote Windows Server, it is possible using the PowerShell. This method is convenient because you don’t have to log in to the remote Windows Server to get the features.

Run the following command in the PowerShell window to get the list of Windows features installed on the remote server. The below command gets all the installed features on a remote server whose name begins with remote.

Get-WindowsFeature -ComputerName "ServerName" -Name *Remote*
Find Installed Features on Remote Windows Server

Find Installed Features on Remote Windows Server

You can find the list of installed features on multiple remote Windows servers using the below PowerShell command. Before you run the command, substitute the computer names with the server names.

Invoke-Command -ComputerName computername1,computername2 -ScriptBlock {Get-WindowsFeature *remote*}
Find Installed Features on multiple Remote Windows Servers

Find Installed Features on multiple Remote Windows Servers

Read Next

  • How to Uninstall Windows Updates using PowerShell
  • How to Change RDP Port using PowerShell
  • List all Azure Regions using PowerShell | Azure Cloud Shell
  • List of Useful TPM PowerShell CmdLets
  • How to Get Public IP Address Using PowerShell

Still Need Help?

If you need further assistance on the above article or want to discuss other technical issues, check out some of these options.

The `Get-WindowsFeature` cmdlet in PowerShell allows you to retrieve a list of all installed roles and features on a Windows server, providing insights for system management and configuration.

Get-WindowsFeature | Where-Object { $_.Installed -eq $true }

Understanding Roles and Features

What Are Roles?

In the context of Windows Server, roles are specific functionalities that can be installed on a server to fulfill a specific job. For instance, the Web Server (IIS) role allows the server to host websites, while the Active Directory Domain Services role provides directory services needed for domain management.

What Are Features?

Features, on the other hand, are additional capabilities or functionalities that enhance the server’s performance or provide necessary functions. For example, Hyper-V is a feature that allows for virtualization, enabling you to run multiple operating systems on one physical machine.

Difference Between Roles and Features

Understanding the difference between roles and features is crucial for effective server management. Roles are essential for defining the primary tasks of a server, while features serve as enhancements that provide supplementary functions. The correct management of both ensures optimal server performance and functionality.

Install-Module PnP.PowerShell: A Quick Start Guide

Install-Module PnP.PowerShell: A Quick Start Guide

Getting Started with PowerShell

What is PowerShell?

PowerShell is a task automation framework that includes a command-line shell and associated scripting language. It offers system administrators powerful tools and commands for managing Windows systems, making it an essential skill for anyone involved in IT management.

Opening PowerShell

To get started, you’ll need to open PowerShell. Here are the steps for different Windows versions:

  • On Windows 10 or later, you can search for “PowerShell” in the Start menu. Right-click and select Run as administrator to access full capabilities.
  • On Windows Server, type in PowerShell in the search bar and select it, ensuring to run it with administrative privileges.

Install Windows Updates PowerShell: A Simple Guide

Install Windows Updates PowerShell: A Simple Guide

The `Get-WindowsFeature` Cmdlet

To get installed roles and features, you use the `Get-WindowsFeature` cmdlet. This command is the backbone of querying roles and abilities present on your server.

Basic Syntax

Here’s the basic command to retrieve all installed roles and features:

Get-WindowsFeature

When executed, this command lists all features and roles, along with their installation status. The output includes columns that display the feature name and its installation state, typically showing if it’s installed, available, or removed.

Filtering Results

Using the `-Name` Parameter

Sometimes, you may want to focus on a specific role or feature. You can use the `-Name` parameter with wildcards to filter results. Here’s how you can check for features related to IIS:

Get-WindowsFeature -Name *Web*

This command returns only those features whose names include «Web», helping you narrow your focus to relevant items.

Using the `-IncludeAllSubFeature` Parameter

To get not just the main features but all associated sub-features, you can utilize the `-IncludeAllSubFeature` parameter:

Get-WindowsFeature -IncludeAllSubFeature

By doing this, you ensure a comprehensive output, including every sub-feature beneath the main capabilities.

Checking Installation Status

When using `Get-WindowsFeature`, you’ll notice features displayed alongside their installation statuses, such as Installed, Available, and Removed. It’s essential to understand these statuses for effective server management.

Example of Checking Specific Feature Status

To check the installation status of a specific feature, you could run:

Get-WindowsFeature -Name Web-Server

The output clearly indicates whether the Web Server role is installed or not, allowing for quick checks in your server management tasks.

Install Telnet in PowerShell: A Simple Step-by-Step Guide

Install Telnet in PowerShell: A Simple Step-by-Step Guide

Output Formatting

Formatting Output with `Select-Object`

If you want to refine the output for clarity, you can pipe the results into `Select-Object` to display only specific details:

Get-WindowsFeature | Select-Object DisplayName, InstallState

This command modifies the displayed columns, providing a cleaner view that emphasizes the names and installation states of roles and features.

Exporting Data to CSV

For documentation or reporting purposes, you may want to export the list of installed features to a CSV file. This can be accomplished easily:

Get-WindowsFeature | Export-Csv -Path "InstalledFeatures.csv"

Using this command allows you to save the output in a structured format, facilitating further analysis or reporting.

Get NetAdapter PowerShell: Mastering Network Queries

Get NetAdapter PowerShell: Mastering Network Queries

Advanced Techniques

Using PowerShell Remoting

PowerShell remoting is a powerful feature that allows you to execute commands on remote servers. This is useful when managing multiple servers. For instance, you can check installed features on a remote machine using the following command:

Invoke-Command -ComputerName RemoteServerName -ScriptBlock { Get-WindowsFeature }

This command executes `Get-WindowsFeature` on `RemoteServerName`, providing you with the same output as if you were running it locally.

Understanding and Utilizing Modules

PowerShell operates in a modular framework, where various cmdlets are grouped into modules. Some specific modules may enhance your capabilities regarding roles and features, although `Get-WindowsFeature` comes built-in with Windows. Familiarizing yourself with available modules can empower your management tasks further.

Intune Install Command PowerShell: A Simple Guide

Intune Install Command PowerShell: A Simple Guide

Troubleshooting Common Issues

PowerShell Execution Policies

When running PowerShell commands, you might encounter issues related to execution policies. These policies dictate the conditions under which scripts are run to ensure system security. To view your current execution policy, use:

Get-ExecutionPolicy

If you encounter permission issues, you may need to change the execution policy with:

Set-ExecutionPolicy RemoteSigned

This command allows scripts to be run as long as they are signed by a trusted publisher.

Permissions and Access Rights

Often, access issues arise from insufficient permissions to perform certain tasks. Make sure you are running PowerShell as an Administrator and have adequate permissions to view or modify installed roles and features. If you are part of a domain, make sure your user account has the roles necessary for server management.

Install PowerCLI PowerShell: A Quick Start Guide

Install PowerCLI PowerShell: A Quick Start Guide

Conclusion

By mastering the use of PowerShell to get installed roles and features, you equip yourself with essential skills for effective server management. The commands presented here open doors to a deeper understanding of server functionalities and ensure you can optimize your server environments confidently.

Regular practice with these commands will solidify your knowledge and prepare you for advanced management tasks. Diving deeper into PowerShell beyond the basics can transform your approach to IT administration, making it more efficient and powerful.

Brew Install PowerShell: A Quick Start Guide

Brew Install PowerShell: A Quick Start Guide

Call to Action

For those eager to enhance their PowerShell skills further, consider joining our PowerShell training courses. Share your experiences or any questions you have in the comments section to foster a learning community.

PowerShell

If you install Roles and Features with PowerShell, Install-WindowsFeature is your friend. Get-Windowsfeature gets information about installed or available Server Roles. This blog post shows you how to get a list of all installed Roles on Windows Server 2012 or Windows Server 2016.

First of all, I want point out that there is a newer blog post that enables you to retrieve all server roles from all servers. More here: List all Server Roles from all Windows Servers with PowerShell

Get-WindowsFeature

Running without parameters, Get-WindowsFeature gets information about all Server Roles and Features. We are looking for the attribute installstate. Possible values are: Installed, Available, Removed.

Unbenannt.PNG

List all installed Features and Roles

Let´s move on. I am logged on Server03, which is a Member Server of my Domain. I search for all installed Roles on the localhost.

Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"} | Format-List Name,Installstate | more

Unbenannt.PNG

List all roles and Features on a Remote Host

As  mentioned, I am logged on Server03. Let´s find all installed Roles and Features on the remote computer dc01. Server03 and dc01 are in the same domain. I use Get-WindowsFeature with the parameter -ComputerName.

Get-WindowsFeature -ComputerName dc01 | Where-Object {$_. installstate -eq "installed"} | Format-List Name,Installstate | more

Unbenannt.PNG

See also

For installing and listing Windows Server Roles and Features you can also establish a PowerShell Remote Session, which i described in this article: How to configure Trusted Hosts for PowerShell Remote Sessions.

Published by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2025], IT-Trainer, IT-Consultant, MCSE: Cloud Platform and Infrastructure, Cisco Certified Academy Instructor.
View all posts by Patrick Gruenauer

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows server 2012 краткое описание
  • Самый маленький live cd windows 7
  • Windows 200 startup sound
  • Bochs запуск windows xp
  • Ошибка 11b при подключении сетевого принтера windows 10