Database, Software, and System Engineering

Importing and Exporting Windows Features with PowerShell

This applies to Windows 7, Windows Server 2008 and Windows Server 2008 R2 and the use of Get-WindowsFeature and Add-WindowsFeature.  For Windows 8, Windows Server 2012, and Windows Server 2012 R2 Microsoft has overhauled these two cmdlets that I’ll handle the same usage in a different post.

First the cmdlets we need are in the server manager module so import that:

Import-Module ServerManager

Create your windows features xml or text file with the one of the following commands from a reference server:

Get-WindowsFeature | ? { $_.Installed } | Export-Clixml .\Features.xml


Get-WindowsFeature | ? { $_.Installed } | Select Name | ForEach-Object { $_.Name } | Out-File .\Features.txt

To install these features:

$(Import-Clixml .\Features.xml) | Add-WindowsFeature


$(Get-Content .\Features.txt) | Add-WindowsFeature

I prefer the TXT file and a Sort for an easy way to compare the files to easily compare of two servers.  Therefore my final scripts:


Import-Module ServerManager
Get-WindowsFeature | 
  ? { $_.Installed } | 
  Sort-Object Name | 
  Select Name | 
  ForEach-Object { $_.Name } | 
  Out-File .\Features.txt


Import-Module ServerManager
$(Get-Content .\Features.txt) | 

..and you should be all set.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>