Creating DSC configuration

The next step is to write a DSC configuration using any PowerShell editor to reflect the intent of the configuration. For this sample, a single configuration, ConfigureSiteOnIIS, is created. It imports the base DSC module, PSDesiredStateConfiguration, which consists of resources used within the configuration. It also declares a node web server. When this configuration is uploaded and compiled, it will generate a DSCConfigurationNodes named ConfigureSiteOnIISwebserver. This configuration can then be applied to nodes.

The configuration consists of a few resources. These resources configure the target node. The resources install a web server, ASP.NET, and framework, and create an index.htm file within the inetpubwwwroot directory with content to show that the site is under maintenance. For more information about writing DSC configuration, refer to https://docs.microsoft.com/en-us/PowerShell/dsc/configurations.

Configuration ConfigureSiteOnIIS {   
    Import-DscResource -ModuleName 'PSDesiredStateConfiguration'   
    Node WebServer {   
      WindowsFeature IIS  
        {  
            Name = "Web-Server"  
            Ensure = "Present"  
        }         
        WindowsFeature AspDotNet  
        {  
            Name = "net-framework-45-Core"  
            Ensure = "Present"  
            DependsOn = "[WindowsFeature]IIS"  
        }            
        WindowsFeature AspNet45  
        {  
            Ensure          = "Present"  
            Name            = "Web-Asp-Net45"  
            DependsOn = "[WindowsFeature]AspDotNet"  
        }   
        File IndexFile  
        {  
            DestinationPath = "C:inetpubwwwrootindex.htm"  
            Ensure = "Present"  
            Type = "File"  
            Force = $true  
            Contents = "<HTML><HEAD><Title> Website under construction.</Title></HEAD><BODY> `  
             <h1>If you are seeing this page, it means the website is under maintenance and DSC Rocks !!!!!</h1></BODY></HTML>"  
        }  
   }  
}   
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.156.202