The Servermanager.exe CLI tool in Windows Server 2008
In pasts posts I’ve talked a bit about the Server Manager tool that is bundled with Windows Server 2008, that will allow you to set up, configure and monitor different roles in your server installation. Microsoft has also bundle with this new version of Windows a command line version of this tool (only available in full installs of 2008 and not in core) that allows you to:
- Install new roles/features
- List currently installed roles
- Remove server roles
- View the possible outcome of installing a new role before doing so
Also this tool allows you to automate some role installations via answer files, pretty similar (but with XML yey!) as to what we used to do in Windows Server 2003 with unattended installations. This will come in handy to setup IIS quickly in a couple of boxes after doing a fresh install of Windows Server 2008 in case you don’t have an imaging solution already in place that is more practical for these scenarios.
Let’s go quickly over some of available switches for this command line based tool and what they do.
ServerManagercmd.exe –query
Will list all of the currently installed roles (IIS, Active Directory, Terminal Services, etc.) and features (Remote Server Administration tools, telnet client, etc.)
ServeManagercmd.exe -install <role-or-feature-name>
Does pretty much what the command says it does, install a new role such as IIS or Terminal Services, however I would like to exercise a word of caution when using this tool first of all some roles require to reboot your server and you will be prompted for this afer you issue the coomand you can avoid being prompted and reload the server using this command with the -restart switch the complete syntax of this command would be ServeManagercmd.exe -install <role-or-feature-name> -restart
Also I would like to mention the fact that the role names are “case sensitive” and sometimes the name of the role is not spelled out clearly for more information on the usage of this command please review this TechNet document titled Server Manager Technical Overview Appendix.
ServeManagercmd.exe -remove <role-or-feature-name>
Pretty self-explanatory, does the same the contrary effect of install and removes roles be vary careful with this command as the possible impact it can have to you infrastructure could be severe if not used carefully and always remember run a backup before modifying anything of this importance, if it ain’t broken don’t fix it is my motto!
ServeManagercmd.exe -install <role-or-feature-name> -whatif
Provides information as to what exactly would be installed/modified when adding a role pretty useful when a role has sub-dependencies and you would like to know what else would be added to your box.
I also mentioned earlier in this post that you can create answer files for the installation of roles this is done via XML and the documentation for it is avaiable in the document I linked from TechNet above, but for a practical example of a real-world scenario I found this article titled Installing IIS 7.0 using ServerManagerCmd.exe, Additionally for all of the previously explained commands you are allowed to dump the results to an XML formatted file for your viewing pleasure in your favorite XML editor for some info on this please refer to this MSDN blog article titled using ServerManagerCmd.
Windows Networking had a feature on ServerManagerCmd that might be intersting to take a look at as a complement to this post.