Home » Archive » Backup your Server Roles and Features

Backup your Server Roles and Features

The following short script gathers the installed roles and features on a server and outputs them to PowerShell script that can be used to redeploy them on another server. This can be useful during migration scenarios or when you need to deploy an additional server with the same requirements.

Copy the below code and save it as a ps1 file.

$roles = Get-WindowsFeature | Where {$_.installed -eq "Installed"} | Select Name 
$command = "Add-WindowsFeature "
ForEach ($role in $roles){
    $command += $role.Name + "," 
$command = $command.Substring(0,$command.Length-1)
New-Item -Path C:\ -Name "ServerRoles.ps1" -ItemType File -Value $command


When complete produces another ps1 file called ServerRoles.ps1 on the root system drive. Open the file to reveal the install command


Don’t forget if your script is for server 2012, as you need .NetFx3 then you will need to append –Source <path to sxs folder here> to the end of the script.


  1. Reblogged this on We Speak Binary and commented:
    Not just for Skype for Business – this powershell script gathers the installed components for any Windows server, allowing you to automate server run-ups for whatever you’re building. Excellent work!

    • Mark,

      Great and useful script, will most certainly give this a go. A question however, would this backup the config for each of the roles as well or is there a separate step required to do this?


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: