1

I am working with Windows Server 2016.

The PowerShell's Get-WindowsFeature cmdlet gives its output in 3 fields: Display Name, Name and Install State. As per documentation I can filter on Name field but I want to filter on Display Name field. How can I do that?

Also I can see there is hierarchy some times in values of Display Name field. For example .NET Framework 3.5 Features has 3 child items. I want to be able to filter on .NET Framework 3.5 Features Display Name field and can also see its child items. How can I do that?

3 Answers 3

1

You can use Where-Object and -like or -match

Get-WindowsFeature | Where-Object displayname -like '*framework 3.5*'

Get-WindowsFeature | Where-Object displayname -match 'framework 3\.5'

Even though it shows Display Name in the formatted output, it's actually DisplayName as the property name. You can see all its properties by using Get-Member

Get-WindowsFeature | Get-Member
Sign up to request clarification or add additional context in comments.

2 Comments

Actually, the -match uses regex, so you should escape the dot (or any other character that has special meaning in regex) by prefixing it with a backslash.
You’re absolutely right. My test was just with “framework”. Good looking out Theo.
0

try this:

Get-WindowsFeature | where {$_."Display Name" -like "*yoursearch*"}

Comments

-1
$search = Get-WindowsFeature "NET-Framework-Features"
$search.subfeatures

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.