New in Windows Server 2008 is the concept of Roles. Examples of Roles for your server are:
- Web Server (IIS)
- Sharepoint Server
- Windows Active Directory (AD) Server
While it is easy to add these roles in the Windows Server 2008 GUI (see Figure 1, below), what if you had to or wanted to add & remove roles at the Windows Server 2008 Command prompt? How would you do it? Let’s find out…
Figure 1: Adding Roles with the Windows Server 2008 GUI
What is ServerManagecmd.exe?
Just like the new “Role” concept that is new Windows Server 2008, you are offered a new CLI tool to manage those Roles. That tool is ServerManagercmd.exe.
With ServerManagercmd.exe, you can do the following:
- Query installed roles on the Windows 2008 Server & send output to an XML file if you choose.
- Use an answer file as input for certain roles being installed.
- Install new Server 2008 Roles, perform logging on the install, select sub-features to be installed, and perform “what if” analysis on what the results of the install would be.
- Remove Windows Server roles.
How do I Query Windows Server 2008 Roles with ServerManagercmd?
To get a complete list of all the current roles installed on your server just use the “-query” option. You can shorten this to “-q”. Here is what it looks like:
Figure 2: Results of ServerManagercmd.exe –Query command
Figure 3: ServerManagercmd.exe command shows that one role is installed
As you can see from the output, this server has one Role installed – that of the Network Policy and Access Server. ServerManagerCMD does change the text of the output yellow if a service is installed.
Notice how every Role has a “command value” next to it. For example, the Network Policy and Access Services Role has “NPAS” next to it. If you were to add or remove the NPAS service, you would have to provide the command value.
You can look up all the command values by going to the official Microsoft ServerManagercmd TechNet documentation. Here are some of the examples for the more popular Roles:
- Print Server = Print-Services
- Terminal Server = TS-Terminal-Server
- Active Directory Domain Controller = ADDS-Domain-Controller
- DNS Server = DNS
- Windows 2003 File Services = FS-Win2003-Services
- IIS Web Server only = Web-WebServer
And you should note that every sub-role of these roles has its own sub- role command identifier. For example, to install Terminal Server, you will likely also need to install Terminal Services Licensing, coded TS-Licensing.
How do I Install a Role with ServerManagercmd.exe?
Once you know the proper command identifier for the role (and sub roles) that you want to install, actually installing the Roles is easy. Here is an example of my installation of Windows Server 2008 Printing Services. Notice how I just typed servermanagercmd –install Print-Services:
Figure 4: ServerManagercmd.exe installation of Windows Print Services
The installation was successful but we are told that we must reboot the server for the install to take effect. To prevent this, I could have done:
servermanagercmd –install Print-Services –restart
And the reboot would have automatically occurred.
But what if there are a lot of sub-features in the case of a package like Terminal Services? How can I prevent having to run multiple ServerManagercmd.exe commands?
There are a couple of options here. First, some of the roles you may want to install have “umbrella” commands. For example, if you want to install all IIS related roles, you can use Web-Server, like this:
servermanagercmd –install Web-Server
This command would install not only IIS but also things like HTTP Errors, ASP, ASP.NET, CGI, Web Security, and more.
Here is an example of my installation of Windows IIS Web Server using the main command option, which installs the main role and all sub-roles:
Figure 5: Installing the umbrella command options
How do I remove a Role with ServerManagercmd?
As you have probably figured out, removing roles works the reverse as installing roles. To remove a role, just use the –remove option, like this:
Figure 6: Removing a Windows Server 2008 Role with ServerManagercmd.exe
What else should I know?
I really like the “what if” feature. With this command option, you can see what an installation would look like without really having to do the installation. To use this option, just use the regular installation command syntax but, at the end, throw in the –whatif command line switch. Here is an example:
Figure 7: Using the WhatIF Switch when installing with ServerManagercmd.exe
Can I install Features as well as Roles with ServerManagercmd.exe?
Absolutely, you can install Windows Server 2008 Features with ServerManagercmd.exe – not just roles. Here is a short list of just some of the features you can install:
- Network Load Balancing = NLB
- .NET Framework 3.0 = NET-Framework (umbrella command)
- Wireless Neworking = Wireless-Networking
- Telnet Client = Telnet-Client
- Windows Power Shell = PowerShell
- Group Policy Management = GPMC
(note that these are just a few of the many features you can install)
Here is an example of my installation of the Windows Server 2008 telnet client:
Figure 8: Installing the Windows Server 2008 Telnet client with ServerManagercmd
Figure 9: Telnet client successfully working
After being used to having a built-in telnet client, it is frustrating with Windows Server 2008 when it isn’t there anymore. Notice in Figure 8 how the telnet command didn’t work, I installed the Telnet client with Server Managercmd and, after that, the telnet client was available.
What else should I know?
One common question about the ServerManagercmd command is, can I use this in Windows Server Core (see WindowsNetworking.com – Creating a Core Longhorn Server)?
Unfortunately, the answer is no. As ServerManagercmd uses the .NET framework and as that is not available in Windows Server Core, ServerManagercmd does not work. However, what does work is this – the OCSetup and OCList command.
Also, keep in mind that you (or another admin) cannot be using the “Add Roles Wizard” and run a ServerManagercmd.exe command at the same time. If you do, you will get the following friendly error:
Figure 10: Error when trying to us GUI and CLI at the same time
The ServerManagercmd.exe application is a very necessary command for any Windows system administrator to understand. With ServerManagercmd, you can query, install, or remove Windows Server 2008 Roles and Features. This includes small features like the Telnet client and larger, more important roles like Windows Active Directory, File Services, DHCP, DNS, Terminal Services, and IIS Web Server. While ServerManagercmd isn’t as pretty as a GUI tool, it is certainly just as function and it could even be quicker or easier, once you have tried it.
For the full technical ServerManagercmd.exe command syntax, please see the official Microsoft ServerManagercmd TechNet documentation