12.Sep.2009 |
by Gusac |
Filed in: Articles, Tutorials
Most of us are already familiar with the Roles and Features in Windows Server 2008 and have been adding/removing them through Server manager console. Windows server 2008 also offers a command line tool to enable administrators to install roles and features through command line. The tool, ServerManagerCmd.exe lets you query, install or remove the roles/features on Windows server 2008.
Servermanagercmd.exe also lets administrators automate the installation and removal of roles and features. It uses the XML answer file to automate the process.
We’ll cover the available switches with servermanagercmd.exe tool here but before we so that, there are few things to keep in mind:
- Running ServerManagerCmd.exe tool requires elevated privileges.
- You need to be a member of administrators group
- ServerManagerCmd.exe command does NOT work on Windows Server Core because .NET Framework, required for ServerManagerCmd.exe, is not available in Windows Server Core.
ServerManagerCmd.exe has the following switches:
- -query
- -install
- -remove
- -inputPath
- -version
- -help
Query or List the Roles and Features:
|
|
To display a list of all roles, role services, or features installed and available for installation on the server.
Syntax: servermanagercmd -query Note: You can alos use the short form of the -query parameter, -q
- To save the query results in XML format: -query Query.xml
Syntax: servermanagercmd -query query.xml
- To save the logs: -query -logpath [log.txt]
Syntax: servermanagercmd -query -logpath [log.txt] Note: log.txt file name is optional. If you do not a name and a location for the log file, the default will be created as %WINDIR%\temp\servermanager.log.
|
|
|
Install the Roles and Features:
|
|
To install the role, role service, or feature specified. We need to the identifier for the roles, roles services or features to be installed. Note that every role, role service or feature has an associated identifier or ID which is needed while installing/removing it.
Syntax: servermanagercmd –install ID |
|
To restart the system automatically after completing installatiion Note that, the install switch does not restart the system after completing the installation. However, Some of the roles, role services or features require reboot. To restart the system automatically after finishing installation use the -restart switch.
Syntax: servermanagercmd –install ID -restart |
|
To install all the child role, role services or features Use the the switch -allSubFeatures to install a role or feature with all the child role services or features. This would avoid running multiple instances of servermanagercmd.exe command for each sub feature.
Syntax: servermanagercmd –install ID -allSubFeatures |
|
To save the result of the installation results to a xml file Saves installation results to an XML file represented by result.xml. You can also use the short form of this parameter, -r
Syntax: servermanagercmd –install ID -resultpath -result.xml OR servermanagercmd –install ID -r -result.xml |
|
To enable logging Specified the name and path for the log file. If you do not provide the log file name, it will save the logs to the default location: %WINDIR%\Temp\Servermanager.log.
Syntax: servermanagercmd –install ID -logpath -log.txt |
|
|
Remove the Roles and Features:
|
|
To remove the role, role service, or feature specified. We need to the identifier for the roles, roles services or features to be removed. Note that every role, role service or feature has an associated identifier or ID which is needed while installing/removing it.
Syntax: servermanagercmd –remove ID |
|
To restart the system automatically after completing the uninstallatiion Note that, the remove switch does not restart the system after completing the uninstallation. However, Some of the roles, role services or features require reboot. To restart the system automatically after finishing uninstallation use the -restart switch.
Syntax: servermanagercmd –remove ID -restart |
|
To uninstall all the child role, role services or features Use the the switch -allSubFeatures to removee a role or feature with all the child role services or features. This would avoid running multiple instances of servermanagercmd.exe command for each sub feature.
Syntax: servermanagercmd –remove ID -allSubFeatures |
|
To save the result of the uninstallation results to a xml file Saves uninstallation results to an XML file represented by result.xml. You can also use the short form of this parameter, -r
Syntax: servermanagercmd –remove ID -resultpath -result.xml OR servermanagercmd –remove ID -r -result.xml |
|
To enable logging Specified the name and path for the log file. If you do not provide the log file name, it will save the logs to the default location: %WINDIR%\Temp\Servermanager.log.
Syntax: servermanagercmd –remove ID -logpath -log.txt |
|
|
Using an Answer file to install or remove Roles and Features:
|
|
As an administrator you would like to automate the isntallation process for better manageability and ease of use. Servermanagercmd lets you do that with a switch, that is, -inputPath You can also use the switch -p instead of -inputPath. This switch requires the location of the answer file which specifies all the roles, role services or features to be installed or removed. You can check Microsoft Technet article on how to create answer files, Click here.
Syntax: servermanagercmd –inputPath -answer.xml ID OR
|
|
To restart the system automatically after installing or removing Roles and Features
Syntax: servermanagercmd -install –inputpath answer.xml -restart
|
|
To save the result to a xml file Saves the results to an XML file represented by result.xml. You can also use the short form of this parameter, -r
Syntax: servermanagercmd –install -inputpath answer.xml -resultpath -result.xml OR servermanagercmd –install -inputpathanswer.xml -r -result.xml |
|
To enable logging Specified the name and path for the log file. If you do not provide the log file name, it will save the logs to the default location: %WINDIR%\Temp\Servermanager.log.
Syntax: servermanagercmd –install -inputpath answer.xml -logpath -log.txt |