Duplicate Windows Servers: install Roles and Features with PowerShell

RSAT Tools are usually considered  system administrator’s best friend, offering access to servers directly from any workstation and SCCM for os/sw/updates deployments in enterprise and medium company is maybe even more!

When workloads increase or for testing purpose is a very common request to provision a server with the same specs of an existing one,  a fresh installed clone.

Without getting to much into detail the first step is spin up a VM with the same OS and resources.

Installing roles and feature is usually performed  remotely most of the times without need to connect via RDP.  Comparing Roles and Features installed can be performed remotely :

Once connected is required to import  ServerManager Powershell module:

To obtain a list of the installed roles and feature on the remote server:

Important Note : Get-WindowsFeature can be ran remotely with -computername in order to get all feature installed on the target machine.

If we are want to install to the new server all the roles and feature installed on the old one we can

If we want to export it and save it  (even on a shared folder):

To install from xml :

Some feature require restart use -restart option or just add a Restart-Computer at the end of the script.

If you want to repeat this process or do it in a more DevOps way, the best way with PowerShell is DSC (Desired State Configuration).

Leave a Reply

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

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