List Windows Server Roles and Features with PowerShell

I’m sure for anyone who administers Microsoft Windows Server the Server Manager console is an all too familiar place. It does make it easy to add/remove roles and features however PowerShell is another great option that can really speed things up at times.

So – what can we do with PowerShell to list the roles and features on our Windows servers?

List Roles and Features

First let us look at how we can display a list of the roles and features on our server with PowerShell. The command we need is get-windowsfeature which will give us an output such as this –

This is a nice start however if you try the command yourself you will see that it scrolls down the screen listing every single role and feature along with any sub-components. This can be useful and indeed is one way to discover the names you require when building a command to install features however if we just want to see what is installed it is a bit poor.

How can we improve this? Well we have a few options, let us explore them.

Here we take advantage of a switch for this cmdlet. By using the -Name switch and appending a string we can get a list which matches our pattern – in this instance anything matching *Teln*.

It is also possible to pipe the cmdlet through a where clause filter which gives us the option of filtering against the ‘Install State’ –

We can use the same command syntax and use either a ‘Display Name’ or ‘Name’ value to restrict our search to that object as below –

As you see it is easy to select from the ‘Display Name’ or the ‘Name’ field.

 

Further Information

If you would like additional information then as ever Microsoft have a full reference – https://technet.microsoft.com/en-us/library/jj205469.aspx

There are options for running this command against a remote machine but I will be writing a post for remote PowerShell which will cover this type of functionality.

 

Source

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scripting
Install Vmware PowerCLI

PowerCLI is really easy to install now. From an Administrative Powershell window just enter: Install-Module -Name VMware.PowerCLI Minimum Powershell Version must be v3.   Offline Install of PowerCLI Accessing the PowerCLI Modules We’re now ready to download the PowerCLI modules. This task will require a system with internet access. This …

Scripting
Pass credentials with Powershell – 3 Ways

Interactive Here’s your typical scenario.   You have a script that requires credentials internally.  So to provide those credentials you would do something like $MyCredentials=GET-CREDENTIAL –credential “CONTOSO\Username” and you of course see a box like this normally on the screen Then you would type in the password and life would go …

Deployment
MDT – Joining a Computer to a Domain Using PowerShell

Using PowerShell scripts within a task sequence provides more flexibility than using the CustomSettings.ini file to join a computer to a domain. The parameters of the CustomSettings.ini file are common to any deployment you perform. That’s why creating a custom PowerShell script to join your domain will be customize to …