Quickly install features/components with Windows Powershell

Windows 2008 now comes packed with “windows powershell“, allowing administrators and engineers alike to access a powerful CLI more attuned to those that prefer a unix/linux environment. The powershell can be leveraged by customizing your os, administering your domain, or even managing multiple virtualization infrastructures. If you have not heard already, vmware’s powercli is basically a bunch of specially written cmdlets allowing IT staff to automate every portion of your vsphere implementation.

I was tasked with duplicating three production servers for a new staging environment within the same network. For this to occur, it would not be  as simple to just clone and sysprep. For various reasons, I decided to clone from a template, configure the basics, install features, and deploy app/db specific software. The only portion of this that would be time consuming would be getting the roles and features to be the same from production to staging.

Let’s get this done in under two minutes.

Make certain you have opened powershell with admin/elevated rights

• Step 1: Run PowerShell with the ServerManager module:

import-module servermanager

• Step 2: Export the list of currently installed features to XML

Get-WindowsFeature | ? { $_.installed } | Export-Clixml \\server\share\features.xml

• Step 3: On second server, run PowerShell and import XML

$f = Import-Clixml \\server\share\features.xml

• Step 4: Pipe that bad boy into Add-WindowsFeature!

$f | Add-WindowsFeature

• Step 5: Restart, if needed


• Step 6: Go eat a sandwich


After this was completed, I ran the installers for the app/db software and passed back to the client’s dev team for specific data load and deployment.

You can get creative with these types of one-liners when you start making your own scripts and go really nutty with it. For now, this just shows some basic tasks that could potentially save you anywhere from 30 to 90 minutes depending.