Add roles and features to a Windows server with PowerShell

The post describes how you can add a role or feature to a Windows server with PowerShell.

# Create a remote command line connection to the server
Enter-PSSession -Computername <computer> -Credential <domain\username>

# Check if the Remote Desktop Session Host feature is still available
Get-WindowsFeature | where name -Like “rds*”

# Add the Remote Desktop Session Host feature to the server
Install-WindowsFeature RDS-RD-Server -IncludeManagementTools

# If needed (and possible), restart the server
Restart-Computer -Force