PowerShell中的FilterScript
我正在将Windows Server 2012 R2与PowerShell v5一起使用,我偶然发现了一些我不理解的PowerShell行为 以下行工作正常,并按预期返回结果:PowerShell中的FilterScript,powershell,powershell-3.0,Powershell,Powershell 3.0,我正在将Windows Server 2012 R2与PowerShell v5一起使用,我偶然发现了一些我不理解的PowerShell行为 以下行工作正常,并按预期返回结果: Get-WindowsFeature | where -Property "InstallState" -eq "Installed" 这将正常工作,并返回与以前相同的结果: Get-WindowsFeature | where {$_.Installed} 以下内容不起作用,即使它应该起作用: Get-Window
Get-WindowsFeature | where -Property "InstallState" -eq "Installed"
这将正常工作,并返回与以前相同的结果:
Get-WindowsFeature | where {$_.Installed}
以下内容不起作用,即使它应该起作用:
Get-WindowsFeature | where {$_.Available}
但这一点正在发挥作用:
Get-WindowsFeature | where -Property "InstallState" -eq "Available"
我在Windows7上的PowerShellV3上也看到过同样的行为
请给我解释一下
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;}
没有“可用”属性 多谢各位。我知道了。让我困惑的是可能有值“Installed”的属性InstalledState和Installed属性