【问题标题】:Powershell Web Server > Application Development settingsPowershell Web 服务器 > 应用程序开发设置
【发布时间】:2015-02-10 21:05:07
【问题描述】:

我正在尝试编写一个 powershell 脚本来激活

下的所有功能

Web 服务器 (IIS) > Web 服务器 > 应用程序开发

但对于我来说,我无法在网上找到语法。我已经导入了servermanager,甚至运行了下面的代码来查找命令列表,但似乎无法准确找到我需要的内容。

Get-WindowsFeature | 
    Where-Object {$_.Installed -match “True”} | 
    Select-Object -ExpandProperty Name |
    Write-Host

我正在从 GUI 中寻找

编辑

在使用Get-WindowsFeature Web-Server 进行一些工作后,我发现Web-App-Dev 命令引用了我要安装的功能。但是,并非所有这些都被列出。运行以下命令后

Add-WindowsFeature Web-App-Dev

仅安装以下内容

我已经尝试过这种“解决方法”,但是得到了相同的结果。有谁知道如何在应用程序开发节点中安装每个功能?

$features = Get-WindowsFeature Web-App-Dev
$subFeatures = $features.SubFeatures

foreach($item in subFeatures)
{
    Add-WindowsFeature $item
}

【问题讨论】:

标签: powershell windows-server-2012 windows-server-2012-r2


【解决方案1】:

根据文档。在 Windows Server 2008 R2 之后,Add-WindowsFeature 可以用作 Install-WindowsFeature 的别名。 https://technet.microsoft.com/en-us/library/jj205467(v=wps.630).aspx

您可以为此使用选项 IncludeAllSubFeature。

Install-WindowsFeature Web-App-Dev -IncludeAllSubFeature

【讨论】:

    【解决方案2】:

    使用Get-WindowsFeature进行一些调查后发现它:

    Web-App-Dev
    

    为了安装所有子功能,我在下面使用了这个循环

    #install Web Server (IIS) > Web Server > Application Development settings
    $features = Get-WindowsFeature Web-App-Dev 
    $subFeatures = $features.SubFeatures -split " " 
    
    foreach($item in $subFeatures)
    {
        Add-WindowsFeature $item
    }
    

    【讨论】:

      猜你喜欢
      • 2014-03-02
      • 2011-02-11
      • 2012-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-16
      相关资源
      最近更新 更多