首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何通过Powershell启用Windows功能

如何通过Powershell启用Windows功能
EN

Stack Overflow用户
提问于 2013-01-09 21:33:36
回答 4查看 65.7K关注 0票数 28

我需要使用Powershell启用两个Windows功能。但我不知道他们的名字也不知道怎么找到他们。

到目前为止,我已经成功地安装了IIS,并使用一个找到here的脚本停止了默认应用程序池。

代码语言:javascript
复制
function InstallFeature($name) {
    cmd /c "ocsetup $name /passive"
}
InstallFeature IIS-WebServerRole
    InstallFeature IIS-WebServer
        InstallFeature IIS-CommonHttpFeatures
            InstallFeature IIS-DefaultDocument
            InstallFeature IIS-DirectoryBrowsing
            InstallFeature IIS-HttpErrors
            InstallFeature IIS-HttpRedirect
            InstallFeature IIS-StaticContent
        InstallFeature IIS-HealthAndDiagnostics
            InstallFeature IIS-CustomLogging
            InstallFeature IIS-HttpLogging
            InstallFeature IIS-HttpTracing
            InstallFeature IIS-LoggingLibraries
        InstallFeature IIS-Security
            InstallFeature IIS-RequestFiltering
            InstallFeature IIS-WindowsAuthentication
        InstallFeature IIS-ApplicationDevelopment
            InstallFeature IIS-NetFxExtensibility
            InstallFeature IIS-ISAPIExtensions
            InstallFeature IIS-ISAPIFilter
            InstallFeature IIS-ASPNET
    InstallFeature IIS-WebServerManagementTools 
        InstallFeature IIS-ManagementConsole 
        InstallFeature IIS-ManagementScriptingTools

import-module WebAdministration

Stop-WebAppPool DefaultAppPool

解决方案

要搜索:

代码语言:javascript
复制
Get-WindowsFeature *ASP*
Get-WindowsFeature *activation*

要安装:

代码语言:javascript
复制
Add-WindowsFeature NET-Framework-45-ASPNET
Add-WindowsFeature NET-HTTP-Activation
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-01-09 21:39:28

如果您使用的是windows 2008R2,则有一个模块可以实现以下功能:

Import-Module servermanager

此模块导出3个cmdlet:Get-WindowsFeatureAdd-WindowsFeatureremove-WindowsFeature

因此,您可以使用类似get-windowsfeature *frame*的命令来列出.net特性,并通过像Add-WindowsFeature Net-Framework这样的命令进行安装

票数 21
EN

Stack Overflow用户

发布于 2015-12-31 05:05:42

对于较新的Windows客户端操作系统(Windows10/8.1/8),您不能使用Install-WindowsFeature,因为它只用于管理服务器上的功能。尝试使用它将导致一条错误消息:

Windows WindowsFeature:指定的

的目标不能是基于客户端的操作系统。

您可以使用DISM Powershell模块查找和安装可选功能:

代码语言:javascript
复制
gcm -module DISM #List available commands
Get-WindowsOptionalFeature -online | ft #List all features and status
Enable-WindowsOptionalFeature -online -FeatureName NetFx3 -Source e:\Sources\sxs

在最后一个命令中,仅当功能需要引用源文件的安装介质时才需要-Source e:\Sources\sxs (通常是为了修复错误: 0x800f081f无法找到源文件)。.NET框架3.5版似乎是唯一一个需要客户端操作系统的版本,但在服务器操作系统上还有许多其他版本需要参考安装介质的源代码。

票数 41
EN

Stack Overflow用户

发布于 2015-07-29 21:46:40

尝试执行以下操作以获取名称(简称)和显示名称(详细描述):

get-windowsfeature |format-表格-property名称,displayname -AutoSize

使用以下命令安装它们:

安装-WindowsFeature -Name $Name

其中,$Name是get中的name属性

PS: Install-WindowsFeature已取代Add-WindowsFeature

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14236406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档