Managing Server Features with PowerShell Cmdlets on Windows 2008 Server R2 Beta

Managing Server Features with PowerShell Cmdlets on Windows 2008 Server R2 Beta

  • Comments 26

If you have used Windows Server 2008, probably you had experience with managing server features. Server Manager is a traditional way to install/uninstall server features. On Windows 2008 Server R2 Beta, Windows PowerShell provides a new approach to managing server features via Server Manager PowerShell cmdlets. This blog will walk through installing server features with these cmdlets.

To use the Server Manager cmdlets, we need to import servermanager module by running the PowerShell command “Import-Module servermanager”. The reason is that these cmdlets are encapsulated in the servermanager module, and are not a part of PowerShell build-in cmdlets.

image

 

From the console shot above, we can see servermanager module contains three PowerShell cmdlets. Then running “Get-WindowsFeature” will give us a list of Windows feature names. Since this will generate a long list, I will not put the screenshot here. Take .NET Framework 3.5.1 as an example, the feature name is “NET-Framework”. We can go ahead and install this feature. One caveat is you have to run PowerShell as administrator to make “Add-WindowsFeature” work.

image

After the last cmdlet is complete, [X] in the “Display Name” indicates the feature has been added. To be sure, you can always double check with the Server Manager UI. BTW, These cmdlets also work with managing server roles. An example is “Add-WindowsFeature Web-Server” will install Web Server (IIS) role.

It is easy, huh?

Xin Li

Windows PowerShell Team

Leave a Comment
  • Please add 2 and 3 and type the answer here:
  • Post
  • It doesn't seem useful to have the "[ ]" and "[x]" text as part of the Display Name especially in an object/Powershell world. It should be a different column such as "Installed" with a boolean value. It's against the spirit of object pipelines to have to parse strings again.

  • Thanks for your feedback. I will pass your suggestions to our team.

  • Nick,

    Here is a response from the team member who implemented this feature.

    "It’s a custom table formatting.  We introduce that formatting for people who are used to existing ServerManagerCmd.exe, each entry is still an object.  In fact, each entry still have Installed property.   The user can pipe the output to Format-List to see all the properties. "

    Run "servermanagercmd.exe -query", you will see the reason behind this design decision.

    Again, we truly appreciate your feedback.

  • Ok, sounds good as long as we still have the other properties to manipulate. Hard to see behind a screenshot :)

    Thanks

  • is import-module introduced from PS 2.0?

    can we do server management in PS 1.0?

  • For your first question. The answer is yes, see the difference between PS 1.0 and PS2.0 CTP3 at http://www.nivot.org/2009/02/04/DifferencesBetweenPowerShell10RTMAndPowershell20CTP3Win7Beta.aspx . Therefore, the answer for the 2nd question would be no.

  • What would be the equivalent powershell command to the following servermanagercmd command:

    servermanagercmd -query query.xml

  • The equivalent powershell command is: Get-WindowsFeature

  • Does this command display the content as XML?

  • So, where before I have a command script that ran "servermanagercmd -inputpath iis7install.xml" to install specific IIS components, now I need to open powershell (run as administrator (not an easy feat for a script)), Import the servermanager module, then run the Add-WindowsFeature command.  This does not seem like progress to me, I think I prefer the old way.

    I assume there is a way to tell the Add-WindowsFeature command to take an xml file as input for eactly which features to install.

    I think people forget that sometimes we have to write scripts for other people to execute so that those people don't have to learn how to make it work to just do their job.

  • Agreed.  I want to build a machine the way i like it and then output the list of components in a format that can be input by another process.  the fact that servermanagercmd's query and input XMLs used different schemas is obsurd.  What is the best method for doing this?

  • What about Windows 7 features?

  • which cmdlets it is can run on 2008R2 to install feature?

  • which cmdlets it is can run on 2008R2 to install feature?

  • Does Add-WindowsFeature try to event log if any of the features or roles failed  to install ?

Page 1 of 2 (26 items) 12