0

I'm using Windows Server 2012 R2 with PowerShell v5 and I've stumbled on some PowerShell behaviour I don't understand.

The following line working correctly and returning results as expected:

Get-WindowsFeature | where -Property "InstallState" -eq "Installed"

This working correctly and returning results as previous:

Get-WindowsFeature | where {$_.Installed}

The following is NOT working, even though it should:

Get-WindowsFeature | where {$_.Available}

But this one is working:

Get-WindowsFeature | where -Property "InstallState" -eq "Available"

I've seen the same behaviour with PowerShell v3 on Windows 7 as well.

Please explain it to me.

1 Answer 1

2
Get-WindowsFeature | Get-Member -MemberType Property

TypeName: Microsoft.Windows.ServerManager.Commands.Feature

Name                      MemberType Definition                                                                                       
----                      ---------- ----------                                                                                       
AdditionalInfo            Property   hashtable AdditionalInfo {get;}                                                                  
BestPracticesModelId      Property   string BestPracticesModelId {get;}                                                               
DependsOn                 Property   string[] DependsOn {get;}                                                                        
Depth                     Property   int Depth {get;}                                                                                 
Description               Property   string Description {get;}                                                                        
DisplayName               Property   string DisplayName {get;}                                                                        
EventQuery                Property   string EventQuery {get;}                                                                         
FeatureType               Property   string FeatureType {get;}                                                                        
Installed                 Property   bool Installed {get;}                                                                            
InstallState              Property   Microsoft.Windows.ServerManager.Commands.InstallState InstallState {get;}                        
Name                      Property   string Name {get;}                                                                               
Notification              Property   Microsoft.Windows.ServerManager.ServerComponentManager.Internal.Notification[] Notification {g...
Parent                    Property   string Parent {get;}                                                                             
Path                      Property   string Path {get;}                                                                               
PostConfigurationNeeded   Property   bool PostConfigurationNeeded {get;}                                                              
ServerComponentDescriptor Property   psobject ServerComponentDescriptor {get;}                                                        
SubFeatures               Property   string[] SubFeatures {get;}                                                                      
SystemService             Property   string[] SystemService {get;}    

There is no "Available" property.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much. I've got it. The thing that confused me was property InstalledState that might has a value "Installed", and Installed property

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.