Podobnie jak ma to miejsce na systemach serwerowych, na których możemy sprawdzić bieżący stan i zainstalować z poziomu powłoki Windows PowerShell wszystkie role serwera oraz ich usługi i funkcje, również wydania klienckie Windows oferują nam wygodne polecenia powłoki PowerShell umożliwiające szybkie sprawdzenie i włączenie poszczególnych składników systemu. O ile w przypadku Windows Servera skorzystalibyśmy z polecenia Get-WindowsFeature, o tyle systemy klienckie pozbawione są tej komendy i oferują nam polecenie zastępcze o nazwie Get-WindowsOptionalFeature.
Zobaczmy zatem, jak w prosty sposób dowiedzieć się, które ze składników systemu Windows są aktualnie włączone, rozpatrując przy tym różne metody formatowania wyników.
Aby wylistować wszystkie dostępne w systemie składniki korzystamy z tego polecenia z jednym obowiązkowym parametrem, wskazującym czy chcemy odnieść się do działającego lokalnie systemu (parametr -Online), czy też do zachowanego obrazu WIM innej instancji Windows (parametr -Path):
PS C:\Windows\system32> Get-WindowsOptionalFeature -Online Feature Name : Microsoft-Hyper-V-All State : Enabled Feature Name : Microsoft-Hyper-V-Tools-All State : Enabled Feature Name : Microsoft-Hyper-V State : Enabled Feature Name : Microsoft-Hyper-V-Management-Clients State : Enabled Feature Name : Microsoft-Hyper-V-Management-PowerShell State : Enabled Feature Name : Printing-Foundation-Features State : Enabled Feature Name : Printing-Foundation-LPRPortMonitor State : Disabled Feature Name : Printing-Foundation-LPDPrintService State : Disabled Feature Name : Printing-Foundation-InternetPrinting-Client State : Enabled Feature Name : FaxServicesClientPackage State : Enabled Feature Name : ScanManagementConsole State : Disabled Feature Name : LegacyComponents State : Enabled Feature Name : DirectPlay State : Enabled Feature Name : SimpleTCP State : Disabled ...
Po wykonaniu powyższego polecenia cmdlet otrzymamy pełny wykaz poszczególnych składników systemu Windows wraz z ich bieżącym stanem - włączony lub wyłączony.
Jeśli interesują nas jedynie te składniki, które zostały włączone, możemy otrzymane wyniki przepuścić przez dodatkowy filtr, jak w przykładzie poniżej:
PS C:\Windows\system32> Get-WindowsOptionalFeature -Online | Where-Object State -eq "Enabled" Feature Name : Microsoft-Hyper-V-All State : Enabled Feature Name : Microsoft-Hyper-V-Tools-All State : Enabled Feature Name : Microsoft-Hyper-V State : Enabled Feature Name : Microsoft-Hyper-V-Management-Clients State : Enabled Feature Name : Microsoft-Hyper-V-Management-PowerShell State : Enabled Feature Name : Printing-Foundation-Features State : Enabled Feature Name : Printing-Foundation-InternetPrinting-Client State : Enabled Feature Name : FaxServicesClientPackage State : Enabled Feature Name : LegacyComponents State : Enabled Feature Name : DirectPlay State : Enabled ...
Z kolei korzystając ze stanów "Disabled" lub "EnablePending" w podobny sposób możemy wylistować sobie składniki, które są aktualnie wyłączone, lub po włączeniu których wymagany jest restart systemu (przykładem takiego składnika może być chociażby kliencka funkcja Hyper-V, której składnik Microsoft-Hyper-V do momentu ponownego uruchomienia komputera będzie miał po jej włączeniu status EnablePending).
Jak nie trudno zauważyć, tworzona w ten sposób lista jest dosyć długa, dlatego warto sobie otrzymane wyniki przeformatować do postaci bardziej czytelnej tabeli, jak to zrobiliśmy w poniższym przykładzie:
PS C:\Windows\system32> Get-WindowsOptionalFeature -Online | Where-Object State -eq "Enabled" 
                        | Format-Table
FeatureName                                                                      State
-----------                                                                      -----
Microsoft-Hyper-V-All                                                            Enabled
Microsoft-Hyper-V-Tools-All                                                      Enabled
Microsoft-Hyper-V                                                                Enabled
Microsoft-Hyper-V-Management-Clients                                             Enabled
Microsoft-Hyper-V-Management-PowerShell                                          Enabled
Printing-Foundation-Features                                                     Enabled
Printing-Foundation-InternetPrinting-Client                                      Enabled
FaxServicesClientPackage                                                         Enabled
LegacyComponents                                                                 Enabled
DirectPlay                                                                       Enabled
Windows-Defender-Default-Definitions                                             Enabled
MicrosoftWindowsPowerShellV2Root                                                 Enabled
MicrosoftWindowsPowerShellV2                                                     Enabled
Internet-Explorer-Optional-amd64                                                 Enabled
NetFx3                                                                           Enabled
WCF-Services45                                                                   Enabled
WCF-TCP-PortSharing45                                                            Enabled
NetFx4-AdvSrvs                                                                   Enabled
MediaPlayback                                                                    Enabled
WindowsMediaPlayer                                                               Enabled
Microsoft-Windows-MobilePC-LocationProvider-INF                                  Enabled
Printing-XPSServices-Features                                                    Enabled
MSRDC-Infrastructure                                                             Enabled
SearchEngine-Client-Package                                                      Enabled
Xps-Foundation-Xps-Viewer                                                        Enabled
WorkFolders-Client                                                               Enabled
SMB1Protocol                                                                     Enabled
Idąc dalej tym tropem, skoro jawnie żądamy wyświetlenia tylko i wyłącznie składników włączonych, możemy śmiało ograniczyć prezentowane wyniki jedynie do nazw rozważanych pakietów, pomijając przy tym wszelkie dodatkowe informacje:
PS C:\Windows\system32> Get-WindowsOptionalFeature -Online | Where-Object State -eq "Enabled" 
                        | Format-Wide
Microsoft-Hyper-V-All                                     Microsoft-Hyper-V-Tools-All
Microsoft-Hyper-V                                         Microsoft-Hyper-V-Management-Clients
Microsoft-Hyper-V-Management-PowerShell                   Printing-Foundation-Features
Printing-Foundation-InternetPrinting-Client               FaxServicesClientPackage
LegacyComponents                                          DirectPlay
Windows-Defender-Default-Definitions                      MicrosoftWindowsPowerShellV2Root
MicrosoftWindowsPowerShellV2                              Internet-Explorer-Optional-amd64
NetFx3                                                    WCF-Services45
WCF-TCP-PortSharing45                                     NetFx4-AdvSrvs
MediaPlayback                                             WindowsMediaPlayer
Microsoft-Windows-MobilePC-LocationProvider-INF           Printing-XPSServices-Features
MSRDC-Infrastructure                                      SearchEngine-Client-Package
Xps-Foundation-Xps-Viewer                                 WorkFolders-Client
SMB1Protocol
A co jeśli interesuje nas stan jednego konkretnego składnika? Innymi słowy, jak szybko sprawdzić czy przykładowo funkcja Hyper-V została w systemie włączona? Aby to zrobić, wystarczy posłużyć się dodatkowym parametrem polecenia Get-WindowsOptionalFeature o nazwie -FeatureName, dla którego podajemy interesujący na składnik systemu Windows:
PS C:\Windows\system32> Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
Feature Name      : Microsoft-Hyper-V
Display Name      : Platforma Hyper-V
Description       : Udostępnia usługi umożliwiające tworzenie maszyn wirtualnych i ich zasobów
                    oraz zarządzanie nimi.
Restart Required  : Possible
State             : Enabled
Custom Properties :

