本文介绍了如何通过 Powershell 启用 Windows 功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 Powershell 启用两个 Windows 功能.但我不知道他们的名字,也不知道如何找到他们.

I need to enable two Windows Features using Powershell. But I don't know their names or how to find them.

到目前为止,我已经成功安装了 IIS 并使用 此处 找到的脚本停止了默认应用程序池.

So far I have managed to install the IIS and stop the Default Application Pool using a script found here.

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 有一个模块:

if you are in windows 2008R2 there is a module for this :

Import-Module servermanager

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

this module exports 3 cmdlets : Get-WindowsFeature, Add-WindowsFeature and remove-WindowsFeature

所以你可以做一些像get-windowsfeature *frame* 列出 .net 功能并通过类似命令安装它Add-WindowsFeature Net-Framework

so you can make someting likeget-windowsfeature *frame* to list the .net features and install it via command like Add-WindowsFeature Net-Framework

这篇关于如何通过 Powershell 启用 Windows 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 05:23