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 25

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 4 and 1 and type the answer here:
  • Post
  • The PowerShell progress for Add-WindowsFeature is broken. The command never completes progress, causing old progress bands to pile up in Windows PowerShell, obscuring any useful data. I realize that you've already shipped this beast - so, perhaps you could give the rest of us a clue what id or parent id you are using in this cmdlet, so that the nefarious progress relics can be removed. I've tried experimentally calling write-progress -completed with a lot of different potential id values, but have failed to discover the values used by this cmdlet. This really sucks when you are scripting and the progress is hijacked by one of the first cmdlets you call... which this is HIGHLY likely to be.

  • Could you please give an example how to use these cmdlets from outside the PowerShell shell ? I want to install various roles and features with a cmd for which I previously used servermanagercmd in connection with an XML file. If I have to load the cmdlets prior to be able to use them I gues it's a bit more then just a "powershell -command get-windowsfeature".

  • I am lookinng for the same information as Nick:

    Nick 16 Nov 2009 11:38 AM

    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.

    Could someone from the PowerShell Team kindly come back and provide some answers/clues?

    I am so tired of this vistization process... :(((

  • Cameron,

    I faced the same problem a few minutes ago. I found a workaround.

    $ProgressPreference= 'SilentlyContinue'

    Add-WindowsFeature Backup

    I think there's no way to hide the progress bar. ...when is this fixed?

  • Is there a comparable module for windows 7 x64?  when I try to run "Import-Module ServerManager" I get the following error:

    "The specified module 'ServerManager' was not loaded because no valid module file was found in any module directory."

    Do I have to download it somewhere?  Is there a different module to use?  Any assistance is greatly appreciated!

  • Dave:

    The servermanager module is only available to Windows 2008 R2.

    See thread: social.technet.microsoft.com/.../2e583895-9dba-4dde-bb8e-60c034589d65

  • I want registry  key that shows desktop exp is enabled any idea ?

  • and how can i do it on 40 servers?

  • Julia - You can use the New-PSSession cmdlet to create a session to your remote servers and then use Invoke-Command to run the Server Manager commands on them.

    Travis Jones [MSFT]

  • How can you do this for Windows 2012 Server? For some reason this has changed.

Page 2 of 2 (25 items) 12