Where-Object not returning any contents

1

I'm getting started with Windows server 2016, and I'm using a CLI only version. I'm trying to determine what features are installed on my Computer. I tried to do so by viewing stuff with

Get-WindowsFeature

Obviously i don't like reading everything manually to see whether or not it's installed. So i would like to only list the things that are actually installed. I tried to do so with the following command:

Get-WindowsFeature | Where-Object {$_."install state" -like "Installed"}

This returns nothing at all (Note that when i view everything there are modules installed). And when i try to run the commando below, i actually get content returned:

Get-WindowsFeature | Where-Object {$_."name" -like "dns"}

What am i doing wrong? Is it a wrong usage of the command, is the underlying name for "install state" something different?

Nick Dewitte

Posted 2017-02-19T12:21:14.277

Reputation: 110

Answers

0

I'm trying to determine what features are installed on my Computer.

Use the following PowerShell command:

This PowerShell one-liner will import the ServerManager module and show Windows roles and features that are currently installed.

Import-module servermanager ; Get-WindowsFeature | where-object {$_.Installed -eq $True} | format-list DisplayName

To just return True or False if a specific role or feature is installed, you can use this (which uses the Hyper-V role as an example):

Import-module servermanager ; (Get-WindowsFeature -name hyper-v).Installed 

For more information, see: http://technet.microsoft.com/en-us/library/cc732757.aspx

Source Show Installed Windows Roles and Features

DavidPostill

Posted 2017-02-19T12:21:14.277

Reputation: 118 938

tl;dr: It works, but has downsides full story: It returns the correct data, but it only shows the displayname, and thus the hierarchy isn't visible anymore. The answer below is better. But still, it works, so thanks! – Nick Dewitte – 2017-02-19T12:44:07.883

@sniker824 Try removing | format-list DisplayName from the command – DavidPostill – 2017-02-19T12:45:41.910

0

Sending the command's output through Format-Custom always helps you determine the property names you are looking for.

In this case:

Get-WindowsFeature | Where-Object {$_.InstallState -like "Installed"}

...will solve your problem.

user477799

Posted 2017-02-19T12:21:14.277

Reputation:

This works. So appearently it was the name that was different in the underlying code. Thanks a lot, Also nice that it keeps the original formatting – Nick Dewitte – 2017-02-19T12:45:11.443