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 because we can easy 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

 

 

 

 

 

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

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 blow:

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

Leave a Reply