Reference
Tutorialmedium

List Installed Roles and Features Using PowerShell on Windows Server

Emanuel DE ALMEIDA
3/13/202603:09 AM 15 min read 0 views
List Installed Roles and Features Using PowerShell on Windows Server

What PowerShell cmdlets are available for listing Windows Server roles and features?

The primary PowerShell cmdlet for listing installed roles and features on Windows Server is Get-WindowsFeature from the ServerManager module. This cmdlet remains unchanged as of Windows Server 2025 and supports both local and remote querying with comprehensive filtering options.

Let's start by verifying your PowerShell environment is ready. Open PowerShell as Administrator and check the ServerManager module availability.

Get-Module -ListAvailable ServerManager

This displays the ServerManager module version. On Windows Server 2025, you'll see version 2.0.0.0 or later. Import the module explicitly if it's not auto-loaded:

Import-Module ServerManager

Verification: Run Get-Command Get-WindowsFeature to confirm the cmdlet is available.

How do you list all available Windows Server roles and features using PowerShell?

Start by examining all roles and features on your local server. This gives you the complete inventory before applying any filters.

Get-WindowsFeature

This command displays three key columns: Name (short identifier), DisplayName (descriptive name), and InstallState (Available, Installed, or Removed). The output shows hundreds of features available on your Windows Server installation.

Pro tip: Pipe to Format-Table -AutoSize for better column alignment on wide displays, especially when working with long feature names.

Verification: Count total features with (Get-WindowsFeature).Count - expect 400+ items on a full Windows Server installation.

How can you filter PowerShell results to show only installed Windows Server features?

The most common use case for server auditing is showing only installed roles and features. Filter the results using the InstallState property:

Get-WindowsFeature | Where-Object InstallState -eq "Installed"

Alternative syntax using PowerShell's shorthand and automatic boolean property evaluation:

Get-WindowsFeature | ? Installed

Both commands produce identical results. The second uses PowerShell's ability to automatically evaluate boolean properties.

Warning: Use exact case for InstallState values. PowerShell can be case-sensitive for string comparisons in certain contexts, so "Installed" is safer than "installed".

Verification: Compare the count of installed vs. total features: (Get-WindowsFeature | ? Installed).Count should be much smaller than the total count.

What's the correct syntax for querying Windows Server roles on remote machines?

Extend your queries to remote servers using the ComputerName parameter. This requires proper WinRM configuration on the target servers.

Get-WindowsFeature -ComputerName "DC01" | Where-Object Installed

For servers requiring specific credentials, use the Credential parameter:

$cred = Get-Credential
Get-WindowsFeature -ComputerName "SRV02" -Credential $cred | Where-Object Installed

The Get-Credential cmdlet prompts for username and password securely, storing them in a PSCredential object.

Pro tip: Test connectivity first with Test-WSMan ServerName before running feature queries. This saves time by identifying connection issues early.

Verification: The output includes the same columns but queries the remote server. When using Invoke-Command alternatives, check that PSComputerName property shows the target server name.

How do you use wildcards to find specific Windows Server features with PowerShell?

Use wildcard patterns to find specific technologies or feature groups. This approach is essential for focused server audits and compliance checks.

Search for all Hyper-V related components:

Get-WindowsFeature *Hyper-V* | Where-Object Installed

Find web-related features using multiple wildcards:

Get-WindowsFeature *IIS*, *Web* | Where-Object Installed

Locate all Active Directory components:

Get-WindowsFeature *AD*, *Domain* | Where-Object Installed

Verification: Each query returns only features matching the wildcard pattern. Use Get-WindowsFeature *Hyper-V* without the Installed filter to see all Hyper-V features (both installed and available).

What's the difference between Windows Server Roles and Features in PowerShell queries?

Windows Server categorizes components as either Roles (primary server functions) or Features (supporting tools and utilities). You can filter by FeatureType to separate them for different reporting needs.

Show only installed Roles:

Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Role" }

Display only installed Features (not Roles):

Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Feature" }

Format the output for better readability in reports:

Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Role" } | Format-Table Name, DisplayName, FeatureType -AutoSize

Verification: Roles typically include major services like "Web Server (IIS)", "DNS Server", "Active Directory Domain Services", while Features include supporting tools like "PowerShell ISE", "Telnet Client", "Windows PowerShell Web Access".

How can you query multiple Windows Servers simultaneously using PowerShell?

Use Invoke-Command to query multiple servers concurrently, which is significantly faster than sequential queries when managing large server environments.

$servers = @('SRV01', 'SRV02', 'DC01')
$results = Invoke-Command -ComputerName $servers -ScriptBlock {
    Get-WindowsFeature | Where-Object Installed
}

View results with server identification for clear reporting:

$results | Select-Object PSComputerName, Name, DisplayName, InstallState | Format-Table -AutoSize

For environments requiring authentication, include credentials:

$cred = Get-Credential
$results = Invoke-Command -ComputerName $servers -Credential $cred -ScriptBlock {
    Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Role" }
}
Pro tip: Use the -AsJob parameter with Invoke-Command for very large server lists (50+ servers) to run queries in the background and avoid session timeouts.

Verification: Each result includes PSComputerName showing which server provided the data. Count unique servers with: ($results | Select-Object PSComputerName -Unique).Count

What are the best practices for exporting Windows Server feature lists to CSV files?

Export your findings to CSV files for documentation, compliance reporting, or further analysis in Excel and other tools.

Basic export for a single server:

Get-WindowsFeature | Where-Object Installed | Export-Csv -Path "C:\InstalledFeatures.csv" -NoTypeInformation

For multi-server environments with proper formatting:

$servers = @('SRV01', 'SRV02', 'DC01')
$allFeatures = Invoke-Command -ComputerName $servers -ScriptBlock {
    Get-WindowsFeature | Where-Object Installed | Select-Object Name, DisplayName, InstallState, FeatureType
}
$allFeatures | Select-Object PSComputerName, Name, DisplayName, InstallState, FeatureType | Export-Csv -Path "C:\MultiServerFeatures.csv" -NoTypeInformation

Create separate files for roles and features to improve report organization:

$installed = Get-WindowsFeature | Where-Object Installed
$installed | Where-Object { $_.FeatureType -eq "Role" } | Export-Csv -Path "C:\InstalledRoles.csv" -NoTypeInformation
$installed | Where-Object { $_.FeatureType -eq "Feature" } | Export-Csv -Path "C:\InstalledFeatures.csv" -NoTypeInformation

Verification: Open the CSV files in Excel or use Import-Csv "C:\InstalledFeatures.csv" | Measure-Object to count exported records and confirm data integrity.

How do you troubleshoot common PowerShell issues when listing Windows Server features?

Several common issues can occur when working with Get-WindowsFeature, especially in enterprise environments with mixed server configurations.

"Get-WindowsFeature: The term is not recognized" Error:

This occurs when the ServerManager module isn't loaded or you're running on a client OS. Import the module explicitly:

Import-Module ServerManager

On Windows 10/11 clients, install RSAT tools:

Add-WindowsCapability -Online -Name Rsat.ServerManager.Tools~~~~0.0.1.0

Remote Access Denied Issues:

Configure WinRM on target servers if remote queries fail:

winrm quickconfig

Test connectivity before running feature queries:

Test-WSMan ServerName

Performance Issues with Large Server Lists:

Use job-based execution for better performance:

$job = Invoke-Command -ComputerName $servers -AsJob -ScriptBlock { Get-WindowsFeature | ? Installed }
Receive-Job $job -Wait
Warning: Always test your PowerShell scripts on a small subset of servers before running against your entire infrastructure. Network timeouts and authentication issues can cause incomplete results.

Verification: Use Get-Job to monitor background job status and Remove-Job to clean up completed jobs.

IssueCauseSolution
Cmdlet not recognizedServerManager module not loadedImport-Module ServerManager
Remote access deniedWinRM not configuredEnable-PSRemoting on target
Incomplete resultsInsufficient permissionsRun as Administrator
Slow performanceSequential queriesUse Invoke-Command with -AsJob

This comprehensive approach to listing Windows Server roles and features using PowerShell provides you with the tools needed for effective server management, compliance reporting, and infrastructure documentation. The techniques covered work across Windows Server 2016 through 2025, ensuring compatibility with current and legacy environments.

Execution Steps

1

Verify PowerShell and ServerManager Module

First, confirm your PowerShell environment is ready. Open PowerShell as Administrator and check the ServerManager module availability.

Get-Module -ListAvailable ServerManager

This displays the ServerManager module version. On Windows Server 2025, you'll see version 2.0.0.0 or later.

Import-Module ServerManager

Import the module explicitly if it's not auto-loaded. Verification: Run Get-Command Get-WindowsFeature to confirm the cmdlet is available.

2

List All Available Roles and Features

Start by examining all roles and features on your local server. This gives you the complete inventory before filtering.

Get-WindowsFeature

This command displays three key columns: Name (short identifier), DisplayName (descriptive name), and InstallState (Available, Installed, or Removed). The output shows hundreds of features.

Pro tip: Pipe to Format-Table -AutoSize for better column alignment on wide displays.

Verification: Count total features with (Get-WindowsFeature).Count - expect 400+ items on a full Windows Server installation.

3

Filter to Show Only Installed Features

Now filter the results to show only installed roles and features. This is the most common use case for server auditing.

Get-WindowsFeature | Where-Object InstallState -eq "Installed"

Alternative syntax using the shorthand:

Get-WindowsFeature | ? Installed

Both commands produce identical results. The second uses PowerShell's automatic boolean property evaluation.

Warning: Use exact case for InstallState values. PowerShell is case-sensitive for string comparisons in some contexts.

Verification: Compare the count of installed vs. total features: (Get-WindowsFeature | ? Installed).Count should be much smaller than the total.

4

Query Remote Servers for Installed Features

Extend your queries to remote servers using the ComputerName parameter. This requires proper WinRM configuration.

Get-WindowsFeature -ComputerName "DC01" | Where-Object Installed

For servers requiring specific credentials:

$cred = Get-Credential
Get-WindowsFeature -ComputerName "SRV02" -Credential $cred | Where-Object Installed

The Get-Credential cmdlet prompts for username and password securely.

Pro tip: Test connectivity first with Test-WSMan ServerName before running feature queries.

Verification: The output includes the same columns but queries the remote server. Check that PSComputerName property shows the target server name when using Invoke-Command alternatives.

5

Filter Specific Roles and Features with Wildcards

Use wildcard patterns to find specific technologies or feature groups. This is essential for focused server audits.

Get-WindowsFeature *Hyper-V* | Where-Object Installed

Search for web-related features:

Get-WindowsFeature *IIS*, *Web* | Where-Object Installed

Find all Active Directory components:

Get-WindowsFeature *AD*, *Domain* | Where-Object Installed

Verification: Each query returns only features matching the wildcard pattern. Use Get-WindowsFeature *Hyper-V* without the filter to see all Hyper-V features (installed and available).

6

Distinguish Between Roles and Features

Windows Server categorizes components as either Roles (server functions) or Features (supporting tools). Filter by FeatureType to separate them.

Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Role" }

Show only installed Features (not Roles):

Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Feature" }

Format the output for better readability:

Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Role" } | Format-Table Name, DisplayName, FeatureType -AutoSize

Verification: Roles typically include services like "Web Server (IIS)", "DNS Server", while Features include tools like "PowerShell ISE", "Telnet Client".

7

Query Multiple Servers Simultaneously

Use Invoke-Command to query multiple servers concurrently, which is much faster than sequential queries.

$servers = @('SRV01', 'SRV02', 'DC01')
$results = Invoke-Command -ComputerName $servers -ScriptBlock {
    Get-WindowsFeature | Where-Object Installed
}

View results with server identification:

$results | Select-Object PSComputerName, Name, DisplayName, InstallState | Format-Table -AutoSize

For servers requiring credentials:

$cred = Get-Credential
$results = Invoke-Command -ComputerName $servers -Credential $cred -ScriptBlock {
    Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq "Role" }
}
Pro tip: Use -AsJob parameter with Invoke-Command for very large server lists to run queries in the background.

Verification: Each result includes PSComputerName showing which server provided the data. Count unique servers: ($results | Select-Object PSComputerName -Unique).Count

8

Export Results to CSV for Documentation

Export your findings to CSV files for documentation, compliance, or further analysis in Excel.

Get-WindowsFeature | Where-Object Installed | Export-Csv -Path "C:\InstalledFeatures.csv" -NoTypeInformation

For multi-server exports with better formatting:

$servers = @('SRV01', 'SRV02')
$allFeatures = Invoke-Command -ComputerName $servers -ScriptBlock {
    Get-WindowsFeature | Where-Object Installed | Select-Object Name, DisplayName, InstallState, FeatureType
}
$allFeatures | Select-Object PSComputerName, Name, DisplayName, InstallState, FeatureType | Export-Csv -Path "C:\MultiServerFeatures.csv" -NoTypeInformation

Create separate files for roles and features:

$installed = Get-WindowsFeature | Where-Object Installed
$installed | Where-Object { $_.FeatureType -eq "Role" } | Export-Csv -Path "C:\InstalledRoles.csv" -NoTypeInformation
$installed | Where-Object { $_.FeatureType -eq "Feature" } | Export-Csv -Path "C:\InstalledFeatures.csv" -NoTypeInformation

Verification: Open the CSV files in Excel or use Import-Csv "C:\InstalledFeatures.csv" | Measure-Object to count exported records.

Discussion

Share your thoughts and insights

You must be logged in to comment.

Loading comments...