Enumerate all roles on a Windows Server

Windows Server 2008 resurrects the Server Manager utility, which serves as a launch pad for various roles and features of the server OS. Here's how to see if unnecessary roles are running on your Windows Servers.

Windows Server 2008 R2, as well as the base release of Windows Server 2008, uses the Server Manager snap-in to add roles to the server. This can be for roles such as IIS, which may be required for an application that has a web-based component, or for more core-infrastructure services such as Active Directory Domain Services to make the server function as a domain controller.

The Server Manager snap-in is fairly intuitive in showing what roles are in use and not in use. Figure A shows a sample server with the Server Manager pane displayed. Figure A

Click the image to enlarge.

The issue with the tool is that it doesn't report the details easily. For example, let's say that basic FTP traffic is prohibited on a network, yet IIS (web traffic) is allowed. Without some digging around, it is tough to determine this from the Server Manager console.

You can do this rather swiftly by running two PowerShell scripts: the import-module servermanager and get-windowsfeature (which reports the current state). This is shown in Figure B with a number of the active roles on the server highlighted. Figure B

Click the image to enlarge.

The tool goes on for some time enumerating roles and features on the server; this includes .NET services and Remote Desktop Services (if the server functions as a terminal server). This command can be run as a single script and export the results to a text file when it is saved as a PowerShell script file (.PS1) as shown below:

import-module servermanager | get-windowsfeature > C:\users\rickatron\output.txt

In the example above, the file path is running in the default path of PowerShell on the Windows Server for simplicity. The file path can be changed.

This can be a handy way to benchmark roles and features over time for the Windows Server to see what has changed or what is running and review if what is running is required.

Do you frequently use the get-windowsfeature command? If so, please post in the discussion how you use it.