我需要使用Powershell启用两个Windows功能。但是我不知道他们的名字或如何找到他们。
到目前为止,我已经使用here找到的脚本设法安装了IIS并停止了默认应用程序池。
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
解决方案
寻找:
Get-WindowsFeature *ASP*
Get-WindowsFeature *activation*
安装:
Add-WindowsFeature NET-Framework-45-ASPNET
Add-WindowsFeature NET-HTTP-Activation
最佳答案
如果您使用的是Windows 2008R2,则可以使用以下模块:Import-Module servermanager
此模块导出3个cmdlet:Get-WindowsFeature
,Add-WindowsFeature
和remove-WindowsFeature
这样你就可以像get-windowsfeature *frame*
列出.net功能并通过类似的命令进行安装
Add-WindowsFeature Net-Framework
关于powershell - 如何通过Powershell启用Windows功能,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14236406/