PowerShell provides a practical way to manage Windows Server roles and features, especially on Server Core. The workflow below covers discovery, installation, removal, configuration export, and verification.
1. Identify available roles and features
Run PowerShell with administrative rights on the server. Start by displaying the available role and feature names:
Get-WindowsFeatureThe result includes display names, system names, and installation state. Use the value in the Name column for later commands. States can include Installed, Available, and Removed.
2. Check installed components
Limit the output to installed items:
Get-WindowsFeature | ? Installed -eq $trueWhen the exact name is unknown, use a wildcard. For example:
Get-WindowsFeature -Name web-* | Where installedYou can query another server with -ComputerName:
Get-WindowsFeature -ComputerName ny-spool1 | Where installed | ft Name,InstallstateFor a broader inventory, provide a server list or obtain computer accounts with Get-ADComputer. Save and review the results before changing any system.
3. Install a role or feature
Use Install-WindowsFeature. This example installs DNS and its management tools:
Install-WindowsFeature DNS -IncludeManagementToolsRequired dependencies are installed by default. To preview dependencies and the proposed operation, use:
Install-WindowsFeature -Name UpdateServices -WhatIfRemote installations can specify a target server and multiple role names. -IncludeAllSubFeature adds subordinate features, while -IncludeManagementTools adds management tools. The -Restart switch can reboot the server when required, so use it only during an approved maintenance window.
If the required binaries are not present locally, provide a compatible installation source. For example:
Install-WindowsFeature NET-Framework-Core -Source E:\sources\sxs4. Export and reuse a configuration
Export installed items to XML:
Get-WindowsFeature | ? { $_.Installed } | Export-Clixml .\SRV1_InstalledRoles.xmlA text file is easier to inspect and edit:
Get-WindowsFeature | ? { $_.Installed } | Select Name | ForEach-Object { $_.Name } | Out-File .\SRV1_InstalledRoles.txtAfter copying the file to another server, apply the listed names:
$(Get-Content .\SRV1_InstalledRoles.txt) | Add-WindowsFeatureTest this process before production use. Differences in server versions, dependencies, and existing configuration can affect the final result. Parallel jobs also require a shared path that every host can access and should be validated in a lab first.
5. Remove and verify
Remove a role or feature with:
Remove-WindowsFeature Print-Server -RestartReview service dependencies and the maintenance window before allowing a restart. After every change, run the inventory command again and inspect the operation result. If an item is already installed, an installation can return NoChangeNeeded.
Practical takeaway
Use a controlled sequence: discover the system name, preview dependencies, test the change, execute it during an approved window, and verify the destination afterward. When reusing a role list across servers, compare each target’s baseline and record results separately rather than assuming identical outcomes.
