John Doe
John Doe

Reputation: 105

Get-WindowsFeature and Select-Object not displaying installed state?

I am trying to create a script that would highlight missing features by comparing features I need installed with the installed features on a server, that I placed in my array variable in powershell. But I cannot figure out why the installed state is not displaying on my powershell?

This is the script:

$InstallState = "Install State"

Get-WindowsFeature | Select-Object "Name",$InstallState | Where-Object {$_.$InstallState -like "Available"}

I have also tried this

$InstallState = "Install State"

Get-WindowsFeature | Select-Object "Name",$InstallState

I get the Name, but the Install State is blank.

Upvotes: 0

Views: 1721

Answers (1)

Doug Maurer
Doug Maurer

Reputation: 8868

There is no space. You can see the members with the Get-Member command

Get-WindowsFeature | Get-Member

InstallState              Property   Microsoft.Windows.ServerManager.Commands.InstallState InstallState {get;}

Simply change it to

$InstallState = "InstallState"

Get-WindowsFeature | Select-Object "Name",$InstallState | Where-Object {$_.$InstallState -like "Available"}

Upvotes: 1

Related Questions