Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been asked to specify the features which are installed on a production web server so a replica test environment can be created.

I could point and click my way to the solution but I am curious as to how this could be done through a script. Powershell or WMI spring to mind. The report should show all the key system features which are installed along with version numbers. Ideally it would also give some information about the installed operating system

share|improve this question
up vote 2 down vote accepted

Win32_ServerFeature is what you are looking for if you must script it with WMI. It is only with Windows 2008. Example VBScript code from the MSDN link follows.

strComputer = "FABRIKAM"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFeatureList = objWMIService.ExecQuery _
    ("SELECT Name FROM Win32_ServerFeature")

For Each objFeature In colFeatureList
   WScript.Echo objFeature.Name

share|improve this answer

There is this blog post from MSDN on how to Add, Remove and Query roles on a Windows 2008 Server

From a PowerShell command prompt

servermanagercmd.exe -query roles.xml

See full blog here

share|improve this answer

In Server 2008 R2, it's very simple:

Import-Module ServerManager

Hope this helps

share|improve this answer

The above answers will work for Server 2008R2 (so long as you're running Powershell 5 or better), however if you're intending to pipe this out to Add-WindowsFeature (or generating a DSC script) you probably won't get the desired effect as the above lists will sometimes include sub-features which might not be desirable for your application if some of the sub-features are intentionally disabled.

This version of the above script delivered exactly what I wanted:

Get-WindowsFeature | Where-Object { $_.Installed -eq $true -and $_.SubFeatures.Count -eq 0}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.