PowerShell DSC - 不为Web服务器安装嵌套组件

时间:2015-02-12 19:56:08

标签: powershell dsc

我写过PowerShell DSC Configuration。它工作但不如预期。我正在尝试在其下安装Web-Server和其他功能。当我运行脚本时,它只会安装Web Server (IIS)而不会安装任何其他内容。

这就是我的配置的样子:

$MyConfigData = @{
    AllNodes = @(
        @{NodeName = 'myserver.corp.mycompany.net';Role='TestServer'}
     );
}


configuration TestDSC
{
    param (        
    ) 
    node $allnodes.NodeName
    {
        WindowsFeature Web
        {Name = "Web-Server"; Ensure = "Present"}
        {Name = "Web-WebServer"; Ensure = "Present"}
        {Name = "Web-Common-http"; Ensure = "Present"}
        {Name = "Web-Default-Doc"; Ensure = "Present"}
        {Name = "Web-Dir-Browsing"; Ensure = "Present"}
        {Name = "Web-Http-Errors"; Ensure = "Present"}
        {Name = "Web-Static-Content"; Ensure = "Present"}
        {Name = "Web-Health"; Ensure = "Present"}
        {Name = "Web-Http-Logging"; Ensure = "Present"}
        {Name = "Web-Performance"; Ensure = "Present"}
        {Name = "Web-Stat-Compression"; Ensure = "Present"}
        {Name = "Web-Dyn-Compression"; Ensure = "Present"}
        {Name = "Web-Security"; Ensure = "Present"}
        {Name = "Web-Filtering"; Ensure = "Present"}
        {Name = "Web-Basic-Auth"; Ensure = "Present"}
        {Name = "Web-Windows-Auth"; Ensure = "Present"}
        {Name = "Web-App-Dev"; Ensure = "Present"}
        {Name = "Web-Net-Ext45"; Ensure = "Present"}
        {Name = "Web-Asp-Net45"; Ensure = "Present"}
        {Name = "Web-ISAPI-Ext"; Ensure = "Present"}
        {Name = "Web-ISAPI-Filter"; Ensure = "Present"}
        {Name = "Web-Ftp-Server"; Ensure = "Present"}
        {Name = "Web-Mgmt-Tools"; Ensure = "Present"}
        {Name = "Web-Mgmt-Console"; Ensure = "Present"}
        {Name = "Web-Mgmt-Compact"; Ensure = "Present"}

    }
} 


TestDSC -ConfigurationData $MyConfigData -OutputPath "E:\DSCConfig\TestDSC"

2 个答案:

答案 0 :(得分:0)

您需要为每个功能添加名称的WindowsFeature:

WindowsFeature Server
{
    Name = "Web-Server" 
    Ensure = "Present"
}

WindowsFeature WebServer
{
    Name = "Web-WebServer" 
    Ensure = "Present"
}

WindowsFeature CommonHttp
{
    Name = "Common-http" 
    Ensure = "Present"
}

...

答案 1 :(得分:0)

https://technet.microsoft.com/en-gb/library/dn282127.aspx

请参阅' IncludeAllSubFeature'标志