
PowerShell を使い始めたばかりですが、このコマンドについて質問があります。
Get-WindowsFeature | where installed
インストールされている機能が返されますが、今度はすべての機能を削除または使用可能にしたいのですが、「インストール済み」を削除済み/使用可能に置き換えると何も表示されません。なぜでしょうか?
みんなありがとう!
答え1
あなたの例では、Installed
チェックした はブール型プロパティです。これは true または false であり、 であるすべてのオブジェクトをチェックしていました$True
。
Removed
およびAvailable
は の可能な値でありInstallState
、直接のプロパティではありません。
これは次のように確認できます
PS> Get-Windowsfeature | Get-Member
TypeName: Microsoft.Windows.ServerManager.Commands.Feature
Name MemberType Definition
---- ---------- ----------
<extra removed>
Installed Property bool Installed {get;}
InstallState Property Microsoft.Windows.ServerManager.Commands.InstallState InstallState {get;}
<extra removed>
次のいずれかを試してください:
Get-Windowsfeature | Where-Object { -not $_.Installed }
Get-WindowsFeature | Where-Object { $_.InstallState -eq "Available" }
Get-WindowsFeature | Where-Object { $_.InstallState -eq "Removed" }