Export Installed Roles And Features On Windows Server 2016 And 2012

In this article, I’ll show a very cool PowerShell script code that will show all the Installed roles on a Windows Server 2016 or 2012 and export them to a .CSV file.

The only reason this script Is very good Is that we can easily use It to export a list of roles to a .CSV file as I’ll show below and use another PowerShell code to Install the same roles on a new Server.

This code might be very handy when deploying Windows Containers and porting applications from a VM to a Container.

To get started, I’ll the code below to get all my Installed Roles and Features from my Windows Server.

Get-WindowsFeature | where{$_.Installed -eq $True} | select displayname,name

Export roles

To export all roles to a .CSV file and then use it on another server use the line below

Get-WindowsFeature | where{$_.Installed -eq $True} | select name | Export-Csv C:\scripts\Roles.csv -NoTypeInformation -Verbose

Import roles

Optionally, I could use the .CSV file to Install a new Server with exactly the same roles and features with the cool line of code below:

Import-Csv C:\scripts\Roles.csv | foreach{Add-WindowsFeature $_.name  }

3 thoughts on “Export Installed Roles And Features On Windows Server 2016 And 2012”

  1. The same is working till last step but when I get back to server manager post the last step, I dont see any of the roles or features installed.

Comments are closed.