Powershell – Export a list of installed features on a Windows 2008 server

auditpowershellwindows-server-2008wmi

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

Best Answer

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

Next