Welcome

首页 / 编程脚本 / PowerShell查看Windows功能选项的方法

在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:WindowsLogsDISMdism.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

输出结果为:

NameCaption
Microsoft-Hyper-V-AllHyper-V
Microsoft-Hyper-V-Tools-AllHyper-V 管理工具
Microsoft-Hyper-VHyper-V 平台
Microsoft-Hyper-V-Management-ClientsHyper-V GUI 管理工具
Microsoft-Hyper-V-Management-PowerShellWindows PowerShell 的 Hyper-V 模块
Printing-Foundation-Features打印和文件服务
Printing-Foundation-LPRPortMonitorLPR 端口监视器
Printing-Foundation-LPDPrintServiceLPD 打印服务
Printing-Foundation-InternetPrinting-ClientInternet 打印客户端
FaxServicesClientPackageWindows 传真和扫描
ScanManagementConsole扫描管理
LegacyComponents旧版组件
DirectPlayDirectPlay
SimpleTCP简单 TCPIP 服务(即 echo、daytime 等)
SNMP简单网络管理协议(SNMP)
WMISnmpProviderWMI SNMP 提供程序
Windows-Defender-Default-Definitions
Windows-Identity-FoundationWindows Identity Foundation 3.5
MicrosoftWindowsPowerShellV2RootWindows PowerShell 2.0
MicrosoftWindowsPowerShellV2Windows PowerShell 2.0 Engine
DirectoryServices-ADAM-ClientActive Directory 轻型目录服务
Internet-Explorer-Optional-amd64Internet Explorer 11
NetFx3.NET Framework 3.5 (包括 .NET 2.0 和 3.0)
IIS-WebServerRoleInternet Information Services
IIS-WebServer万维网服务
IIS-CommonHttpFeatures常见 HTTP 功能
IIS-HttpErrorsHTTP 错误
IIS-HttpRedirectHTTP 重定向
IIS-ApplicationDevelopment应用程序开发功能
IIS-NetFxExtensibility.NET Extensibility 3.5
IIS-NetFxExtensibility45.NET Extensibility 4.5
IIS-HealthAndDiagnostics运行状况和诊断
IIS-HttpLoggingHTTP 日志
IIS-LoggingLibraries日志工具
IIS-RequestMonitor请求监视器
IIS-HttpTracing跟踪
IIS-Security安全性
IIS-URLAuthorizationURL 授权
IIS-RequestFiltering请求筛选
IIS-IPSecurityIP 安全
IIS-Performance性能功能
IIS-HttpCompressionDynamic动态内容压缩
IIS-WebServerManagementToolsWeb 管理工具
IIS-ManagementScriptingToolsIIS 管理脚本和工具
IIS-IIS6ManagementCompatibilityIIS 6 管理兼容性
IIS-MetabaseIIS 元数据库和 IIS 6 配置兼容性
WAS-WindowsActivationServiceWindows Process Activation Service
WAS-ProcessModel进程模型
WAS-NetFxEnvironment.NET 环境
WAS-ConfigurationAPI配置 API
IIS-HostableWebCoreInternet Information Services 可承载的 Web 核心
IIS-CertProvider集中式 SSL 证书支持
IIS-WindowsAuthenticationWindows 身份验证
IIS-DigestAuthentication摘要式身份验证
IIS-ClientCertificateMappingAuthentication客户端证书映射身份验证
IIS-IISCertificateMappingAuthenticationIIS 客户端证书映射身份验证
IIS-ODBCLoggingODBC 日志记录
IIS-StaticContent静态内容
IIS-DefaultDocument默认文档
IIS-DirectoryBrowsing目录浏览
IIS-WebDAVWebDAV 发布
IIS-WebSocketsWebSocket 协议
IIS-ApplicationInit应用程序初始化
IIS-ASPNETASP.NET 3.5
IIS-ASPNET45ASP.NET 4.5
IIS-ASPASP
IIS-CGICGI
IIS-ISAPIExtensionsISAPI 扩展
IIS-ISAPIFilterISAPI 筛选器
IIS-ServerSideIncludes服务器端包含
IIS-CustomLogging自定义日志
IIS-BasicAuthentication基本身份验证
IIS-HttpCompressionStatic静态内容压缩
IIS-ManagementConsoleIIS 管理控制台
IIS-ManagementServiceIIS 管理服务
IIS-WMICompatibilityIIS 6 WMI 兼容性
IIS-LegacyScriptsIIS 6 脚本工具
IIS-LegacySnapInIIS 6 管理控制台
IIS-FTPServerFTP 服务器
IIS-FTPSvcFTP 服务
IIS-FTPExtensibilityFTP 扩展性
MSMQ-ContainerMicrosoft Message Queue (MSMQ) 服务器
MSMQ-ServerMicrosoft Message Queue (MSMQ) 服务器核心
MSMQ-TriggersMSMQ 触发器
MSMQ-ADIntegrationMSMQ Active Directory 域服务集成
MSMQ-HTTPMSMQ HTTP 支持
MSMQ-Multicast多播支持
MSMQ-DCOMProxyMSMQ DCOM 代理
WCF-Services45WCF 服务
WCF-HTTP-Activation45HTTP 激活
WCF-TCP-Activation45TCP 激活
WCF-Pipe-Activation45命名管道激活
WCF-MSMQ-Activation45消息队列(MSMQ)激活
WCF-TCP-PortSharing45TCP 端口共享
WCF-HTTP-ActivationWindows Communication Foundation HTTP 激活
WCF-NonHTTP-ActivationWindows Communication Foundation 非 HTTP 激活
NetFx4-AdvSrvs.NET Framework 4.5 高级服务
NetFx4Extended-ASPNET45ASP.NET 4.5
MediaPlayback媒体功能
WindowsMediaPlayerWindows Media Player
Microsoft-Windows-MobilePC-Client-Premium-Package-net网络投影
Microsoft-Windows-MobilePC-LocationProvider-INFWindows 定位程序
Printing-XPSServices-FeaturesXPS 服务
RasCMAKRAS 连接管理器管理工具包(CMAK)
RasRipRIP 侦听器
MSRDC-Infrastructure远程差分压缩 API 支持
SearchEngine-Client-PackageWindows Search
TelnetClientTelnet 客户端
TelnetServerTelnet 服务器
TFTPTFTP 客户端
TIFFIFilterWindows TIFF IFilter
Xps-Foundation-Xps-ViewerXPS 查看器
WorkFolders-Client工作文件夹客户端
SMB1ProtocolSMB 1.0/CIFS 文件共享支持