Search This Blog

Thursday, August 20, 2009

Installing and removing Windows Features via the command line

In this article i will show how to install and remove Windows Features ttough the command line.
By command line i mean the regular shell command and Windows Powershell (V2).

ServermanagerCmd which we know from Windows Server 2008 RTM is no longer the prefered tool to use, as Microsoft wants to encourage administrators to use Powershell.

Installing server roles using ServerManagerCmd
To see what roles are installed you can use following command:
ServerManagerCmd /Query
All Windows Server roles and features are displayed.

To install certain feature or roles use the following command:


ServerManagerCmd -i %ServerRole%



ServerManagerCmd -i web-server

When installing multiple roles, just enter the roles and use as sepperators.

To remove features you can use the same commands, but instead of specifying the Install switch "-i", you need to specify the remove switch "-r".

By adding the -restart switch you are telling Windows that if a reboot is required, the system may issue a restart when execution has finished.


Using powershell is fairly the same procedure. You can swith to powershell by issueing the "powershell" command in the Dos box.

In order to load the servermanager module, you need to load the module by issueing following command


Import-Module ServerManager


Querying the roles and features




Installing roles:


Add-WindowsFeature Web-Server, Application-Server


Notice the sepperator.

Remove Features:


Remove-WindowsFeature Web-Server, Application-Server


You see, adding and removing Windows feature is a simple and quicker procedure as installing them trough the GUI.

No comments:

Post a Comment