Servers

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.

About

Rick Vanover is a software strategy specialist for Veeam Software, based in Columbus, Ohio. Rick has years of IT experience and focuses on virtualization, Windows-based server administration, and system hardware.

3 comments
myjunk53
myjunk53

servermanagercmd.exe -query

donbrookes
donbrookes

Where are these scripts, do i have to get them from microsoft?

sid351
sid351

It looks like the servermanager module is only included with 2008 R2, not the base 2008. The way the article is written implys otherwise, as it firstly mentions the Server Manager plug-in for MMC, which is included on 2008 and 2008 R2, and then goes on to talk about the powershell module afterwards, which is only available in R2.

Editor's Picks