Lists the installed roles and the top-level features of a server, separated, so the output answers what this machine actually does without scrolling through hundreds of sub-features. The role names are handed to the next runbook step, which is what lets a follow-up script branch on whether this is a domain controller or a file server.
powershell
# Report Installed Server Roles and Features
# Single use case: list what this server actually does
#-----------------------------------------------------------------
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
if (-not (Get-Command Get-WindowsFeature -ErrorAction SilentlyContinue)) {
Write-Log "Get-WindowsFeature not available (client OS?)."
return
}
$installed = Get-WindowsFeature | Where-Object { $_.Installed }
$roles = $installed | Where-Object { $_.FeatureType -eq "Role" }
$features = $installed | Where-Object { $_.FeatureType -eq "Feature" -and $_.Depth -le 2 }
Write-Log "================ Roles ($(@($roles).Count)) ================"
foreach ($r in $roles) {
Write-Log "[$($r.Name)] $($r.DisplayName)"
}
Write-Log "================ Top-level Features ($(@($features).Count)) ================"
foreach ($f in $features) {
Write-Log "[$($f.Name)] $($f.DisplayName)"
}
Write-Log "Role report complete: $(@($roles).Count) role(s), $(@($installed).Count) installed component(s) total."
# Pass role names to the next runbook script
$store = (($roles | ForEach-Object { $_.Name }) -join ",")Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Windows Server Roles
Report DHCP Scope Utilization with PowerShell
2026-08-17Create a DNS A Record with PowerShell
2026-08-17Clear the DNS Server Cache with PowerShell
2026-08-17Find the Largest Files in a Folder with PowerShell
2026-08-17Get Folder Sizes with PowerShell
2026-08-17Report SMB Shares and Permissions with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.