使用PowerShell执行Install-WindowsFeature -Name时,如何获取可用安装功能列表?
获取PowerShell中可安装的Windows功能列表
嘿,这个问题我熟!当你准备用Install-WindowsFeature -Name安装Windows功能时,想要快速获取所有可供安装的功能列表,其实有几个针对性的PowerShell命令能帮你搞定,分服务器和客户端系统场景给你捋清楚:
1. 针对Windows Server系统:使用Get-WindowsFeature
这是服务器系统下最常用的命令,能直接列出所有内置的Windows功能及其状态:
- 查看所有功能(包括已安装和未安装的):
Get-WindowsFeature - 只筛选**可供安装(未安装)**的功能:
Get-WindowsFeature | Where-Object {$_.InstallState -eq 'Available'} - 模糊搜索特定功能(比如找IIS相关的所有功能):
Get-WindowsFeature *IIS* - 查看功能的子项详情:
Get-WindowsFeature -Name Web-Server -IncludeAllSubFeature
2. 针对Windows 10/11客户端系统:使用Get-WindowsOptionalFeature
客户端系统的可选功能(比如.NET Framework、Telnet客户端等)需要用这个命令查询:
- 查看当前在线系统的所有可选功能:
Get-WindowsOptionalFeature -Online - 只筛选**未启用(可供安装)**的功能:
Get-WindowsOptionalFeature -Online | Where-Object {$_.State -eq 'Disabled'}
实用小技巧
- 把功能列表导出到CSV文件,方便离线查看和筛选:
# 服务器系统 Get-WindowsFeature | Export-Csv -Path "C:\ServerFeatures.csv" -NoTypeInformation # 客户端系统 Get-WindowsOptionalFeature -Online | Export-Csv -Path "C:\ClientFeatures.csv" -NoTypeInformation - 查看某个功能的详细描述,确认是否是你需要的:
Get-WindowsFeature -Name Web-Server | Select-Object Name, DisplayName, Description
内容的提问来源于stack exchange,提问作者Mike C




