Scripting, Server 2008 R2, Windows
Leave a comment

R2: Server Manager Cmdlets

Windows Server 2008 R2 includes a few cmdlets (Command-lets) to manager server roles and features. Before R2, we had servermanagercmd.exe to add or remove features from command line. At the standard PowerShell console, you will not be able to access these cmdlets without importing the server manager module.

To import the cmdlets, useĀ Import-Module ServerManager at the PowerShell Console. This will enable the following three cmdlets.

You could add a feature, for example .Net Framework, using the Add-WindowsFeature cmdlet.

That is simple..huh.!

Now, here is a limitation. For example, if I want to add RDS-Virtualization feature, using traditional Server Manager GUI, I need to add Remote Desktop Server feature and then select RD Virtualization under that. However, when you use Add-WindowsFeature RDS-Virtualization

But if you go and look at the Server Manager GUI console,

So, RDS-Virtualization is installed but without Remote Desktop Server it is of no use. Add-WindowsFeature cmdlet does not check for the dependency information.

If you look at the Get-WindowsFeature output for any given feature there are multiple properties and one such property is “DependsOn”. So, it is pretty much possible to install the remaining depending features and roles using a simple script. More on that later..!
Update:
The above underlined statement is not completely accurate. On a system with no Hyper-V role, when I tried installing RDS-Virtualization feature, Hyper-V was automatically added as RDS-Virtulaization depends on Hyper-V role. I will continue to post more on this. I am just waiting for the RC build to arrive.

Filed under: Scripting, Server 2008 R2, Windows

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.