While Microsoft server provides a great wizard to manipulate roles and features, you may be also interested in learning about it’s command-line counterpart ServermManagerCmd.exe. The command line oriented tool can be used to determine/install/uninstall roles, role services, and features.
ServerManagerCmd requires an elevated command prompt
ServerManagerCmd is easy to lean and use. Let’s start by finding out which roles, role services, and features are installed on a system. In the Windows command-line prompt type.
servermanagercmd -query > queryresults.txt
Using ServerManagerCmd to install components could not be easier, just use -install in front of servermanagercmd to indicate you wish to install a component. In the Windows command-line prompt type.
servermanagercmd -install fs-fileserver -allsubfeatures
For a complete list of components you should take a look at this page.
To uninstall or remove a component the process is almost the same as the installation, just use -remove to indicate you wish to remove a component. In the Windows command-line type.
servermanagercmd -remove fs-fileserver -allsubfeatures
Windows Server 2003, cmd, server 2008 — Jul 30, 2009