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-WindowsFeatureThis 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 -InstalledThis 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" -IncludeSubFeatureThis 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" -NoTypeInformationThis 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 -InstalledNext, 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.