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

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:
[Code]
ServerManagerCmd /Query
[/Code]
All Windows Server roles and features are displayed.

To install certain feature or roles use the following command:

[Code]

ServerManagerCmd -i %ServerRole%

[/Code]

Example

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.

PowerShell

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

[Code]

Import-Module ServerManager

[/Code]

Querying the roles and features

[Code]

Get-WindowsFeature

[/Code]

Installing roles:


[Code]

Add-WindowsFeature Web-Server, Application-Server

[/Code]

Notice the sepperator.


Remove Features:

[Code]

Remove-WindowsFeature Web-Server, Application-Server

[/Code]


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

No comments:

Post a Comment