在Windows Server 2012中使用PowerShell添加和刪除Windows角色和功能非常方便,但是在windows 8.1上啟用和禁用Windows選項卻略顯雞肋。
比如Get-WindowsOptionalFeature擷取當前所有的Windows功能選項:
複製代碼 代碼如下:
PS> Get-WindowsOptionalFeature -Online | select * -First 1
FeatureName : Microsoft-Hyper-V-All
State : Enabled
Path :
Online : True
WinPath :
SysDrivePath :
RestartNeeded : False
LogPath : I:\Windows\Logs\DISM\dism.log
ScratchDirectory :
LogLevel : WarningsInfo
Microsoft-Hyper-V-All到底是什嗎?是不是下圖中的Windows功能對話方塊中的Hyper-V,還是Hyper-V管理平台。如果能有一個英文的FeatureName和下圖中本地化名稱對應就好了。
PowerShell擷取Windows功能選項
幸好WMI中的Win32_OptionalFeature可以做到這一點:
複製代碼 代碼如下:
Get-WmiObject -Class Win32_OptionalFeature |
Select Name,Caption |
ConvertTo-Html
輸出結果為:
| Name |
Caption |
| Microsoft-Hyper-V-All |
Hyper-V |
| Microsoft-Hyper-V-Tools-All |
Hyper-V 管理工具 |
| Microsoft-Hyper-V |
Hyper-V 平台 |
| Microsoft-Hyper-V-Management-Clients |
Hyper-V GUI 管理工具 |
| Microsoft-Hyper-V-Management-PowerShell |
Windows PowerShell 的 Hyper-V 模組 |
| Printing-Foundation-Features |
列印和文件服務 |
| Printing-Foundation-LPRPortMonitor |
LPR 連接埠監視器 |
| Printing-Foundation-LPDPrintService |
LPD 列印服務 |
| Printing-Foundation-InternetPrinting-Client |
Internet 列印用戶端 |
| FaxServicesClientPackage |
Windows 傳真和掃描 |
| ScanManagementConsole |
掃描管理 |
| LegacyComponents |
舊版組件 |
| DirectPlay |
DirectPlay |
| SimpleTCP |
簡單 TCPIP 服務(即 echo、daytime 等) |
| SNMP |
簡易網路管理通訊協定(SNMP) |
| WMISnmpProvider |
WMI SNMP 提供者 |
| Windows-Defender-Default-Definitions |
|
| Windows-Identity-Foundation |
Windows Identity Foundation 3.5 |
| MicrosoftWindowsPowerShellV2Root |
Windows PowerShell 2.0 |
| MicrosoftWindowsPowerShellV2 |
Windows PowerShell 2.0 Engine |
| DirectoryServices-ADAM-Client |
Active Directory 輕型目錄服務 |
| Internet-Explorer-Optional-amd64 |
Internet Explorer 11 |
| NetFx3 |
.NET Framework 3.5 (包括 .NET 2.0 和 3.0) |
| IIS-WebServerRole |
Internet Information Services |
| IIS-WebServer |
全球資訊網服務 |
| IIS-CommonHttpFeatures |
常見 HTTP 功能 |
| IIS-HttpErrors |
HTTP 錯誤 |
| IIS-HttpRedirect |
HTTP 重新導向 |
| IIS-ApplicationDevelopment |
應用程式開發功能 |
| IIS-NetFxExtensibility |
.NET Extensibility 3.5 |
| IIS-NetFxExtensibility45 |
.NET Extensibility 4.5 |
| IIS-HealthAndDiagnostics |
健全狀態和診斷 |
| IIS-HttpLogging |
HTTP 日誌 |
| IIS-LoggingLibraries |
日誌工具 |
| IIS-RequestMonitor |
請求監視器 |
| IIS-HttpTracing |
跟蹤 |
| IIS-Security |
安全性 |
| IIS-URLAuthorization |
URL 授權 |
| IIS-RequestFiltering |
要求篩選 |
| IIS-IPSecurity |
IP 安全 |
| IIS-Performance |
效能功能 |
| IIS-HttpCompressionDynamic |
動態內容壓縮 |
| IIS-WebServerManagementTools |
Web 管理工具 |
| IIS-ManagementScriptingTools |
IIS 管理指令碼和工具 |
| IIS-IIS6ManagementCompatibility |
IIS 6 管理相容性 |
| IIS-Metabase |
IIS 中繼資料庫和 IIS 6 配置相容性 |
| WAS-WindowsActivationService |
Windows Process Activation Service |
| WAS-ProcessModel |
進程模型 |
| WAS-NetFxEnvironment |
.NET 環境 |
| WAS-ConfigurationAPI |
配置 API |
| IIS-HostableWebCore |
Internet Information Services 可承載的 Web 核心 |
| IIS-CertProvider |
集中式 SSL 憑證支援 |
| IIS-WindowsAuthentication |
Windows 身分識別驗證 |
| IIS-DigestAuthentication |
摘要式驗證 |
| IIS-ClientCertificateMappingAuthentication |
用戶端認證映射身分識別驗證 |
| IIS-IISCertificateMappingAuthentication |
IIS 用戶端認證映射身分識別驗證 |
| IIS-ODBCLogging |
ODBC 日誌記錄 |
| IIS-StaticContent |
靜態內容 |
| IIS-DefaultDocument |
預設文件 |
| IIS-DirectoryBrowsing |
瀏覽目錄 |
| IIS-WebDAV |
WebDAV 發布 |
| IIS-WebSockets |
WebSocket 通訊協定 |
| IIS-ApplicationInit |
應用程式初始化 |
| IIS-ASPNET |
ASP.NET 3.5 |
| IIS-ASPNET45 |
ASP.NET 4.5 |
| IIS-ASP |
ASP |
| IIS-CGI |
CGI |
| IIS-ISAPIExtensions |
ISAPI 擴充 |
| IIS-ISAPIFilter |
ISAPI 篩選器 |
| IIS-ServerSideIncludes |
伺服器端包含 |
| IIS-CustomLogging |
自訂日誌 |
| IIS-BasicAuthentication |
基本驗證 |
| IIS-HttpCompressionStatic |
靜態內容壓縮 |
| IIS-ManagementConsole |
IIS 管理主控台 |
| IIS-ManagementService |
IIS 管理服務 |
| IIS-WMICompatibility |
IIS 6 WMI 相容性 |
| IIS-LegacyScripts |
IIS 6 指令碼工具 |
| IIS-LegacySnapIn |
IIS 6 管理主控台 |
| IIS-FTPServer |
FTP 伺服器 |
| IIS-FTPSvc |
FTP 服務 |
| IIS-FTPExtensibility |
FTP 擴充性 |
| MSMQ-Container |
Microsoft Message Queue (MSMQ) 伺服器 |
| MSMQ-Server |
Microsoft Message Queue (MSMQ) 伺服器核心 |
| MSMQ-Triggers |
MSMQ 觸發器 |
| MSMQ-ADIntegration |
MSMQ Active Directory 網域服務整合 |
| MSMQ-HTTP |
MSMQ HTTP 支援 |
| MSMQ-Multicast |
多播支援 |
| MSMQ-DCOMProxy |
MSMQ DCOM 代理 |
| WCF-Services45 |
WCF 服務 |
| WCF-HTTP-Activation45 |
HTTP 啟用 |
| WCF-TCP-Activation45 |
TCP 啟用 |
| WCF-Pipe-Activation45 |
具名管道啟用 |
| WCF-MSMQ-Activation45 |
訊息佇列(MSMQ)啟用 |
| WCF-TCP-PortSharing45 |
TCP 通訊埠共用 |
| WCF-HTTP-Activation |
Windows Communication Foundation HTTP 啟用 |
| WCF-NonHTTP-Activation |
Windows Communication Foundation 非 HTTP 啟用 |
| NetFx4-AdvSrvs |
.NET Framework 4.5 進階服務 |
| NetFx4Extended-ASPNET45 |
ASP.NET 4.5 |
| MediaPlayback |
媒體功能 |
| WindowsMediaPlayer |
Windows Media Player |
| Microsoft-Windows-MobilePC-Client-Premium-Package-net |
網路投影 |
| Microsoft-Windows-MobilePC-LocationProvider-INF |
Windows 定位程式 |
| Printing-XPSServices-Features |
XPS 服務 |
| RasCMAK |
RAS 連線管理員系統管理組件(CMAK) |
| RasRip |
RIP 接聽程式 |
| MSRDC-Infrastructure |
遠程差分壓縮 API 支援 |
| SearchEngine-Client-Package |
Windows Search |
| TelnetClient |
Telnet 用戶端 |
| TelnetServer |
Telnet 伺服器 |
| TFTP |
TFTP 用戶端 |
| TIFFIFilter |
Windows TIFF IFilter |
| Xps-Foundation-Xps-Viewer |
XPS 檢視器 |
| WorkFolders-Client |
工作資料夾用戶端 |
| SMB1Protocol |
SMB 1.0/CIFS 檔案分享權限設定支援 |