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 ServerManagerThis 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 ServerManagerVerification: 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-WindowsFeatureThis 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.
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 | ? InstalledBoth commands produce identical results. The second uses PowerShell's ability to automatically evaluate boolean properties.
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 InstalledFor servers requiring specific credentials, use the Credential parameter:
$cred = Get-Credential
Get-WindowsFeature -ComputerName "SRV02" -Credential $cred | Where-Object InstalledThe Get-Credential cmdlet prompts for username and password securely, storing them in a PSCredential object.
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 InstalledFind web-related features using multiple wildcards:
Get-WindowsFeature *IIS*, *Web* | Where-Object InstalledLocate all Active Directory components:
Get-WindowsFeature *AD*, *Domain* | Where-Object InstalledVerification: 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 -AutoSizeVerification: 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 -AutoSizeFor 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" }
}-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" -NoTypeInformationFor 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" -NoTypeInformationCreate 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" -NoTypeInformationVerification: 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 ServerManagerOn Windows 10/11 clients, install RSAT tools:
Add-WindowsCapability -Online -Name Rsat.ServerManager.Tools~~~~0.0.1.0Remote Access Denied Issues:
Configure WinRM on target servers if remote queries fail:
winrm quickconfigTest connectivity before running feature queries:
Test-WSMan ServerNamePerformance 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 -WaitVerification: Use Get-Job to monitor background job status and Remove-Job to clean up completed jobs.
| Issue | Cause | Solution |
|---|---|---|
| Cmdlet not recognized | ServerManager module not loaded | Import-Module ServerManager |
| Remote access denied | WinRM not configured | Enable-PSRemoting on target |
| Incomplete results | Insufficient permissions | Run as Administrator |
| Slow performance | Sequential queries | Use 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.



