Skip to content

xWebApplication

Johan Ljunggren edited this page Dec 6, 2023 · 2 revisions

xWebApplication

Important

This resource has been renamed in the latest release, see WebApplication. Bug fixes and new functionality will only be added to the renamed resource.

Parameters

Parameter Attribute DataType Description Allowed Values
Website Key String Name of website with which web application is associated
Name Key String Name of web application
WebAppPool Required String Web application pool for the web application
PhysicalPath Required String Physical path for the web application directory
Ensure Write String Whether web application should be present or absent Present, Absent
SslFlags Write StringArray[] SSLFlags for the application ``, Ssl, `SslNegotiateCert`, `SslRequireCert`, `Ssl128`
AuthenticationInfo Write MSFT_xWebApplicationAuthenticationInformation Hashtable containing authentication information (Anonymous, Basic, Digest, Windows)
PreloadEnabled Write Boolean Allows a Application to automatically start without a request
ServiceAutoStartEnabled Write Boolean Enables Autostart on an Application.
ServiceAutoStartProvider Write String Adds a AutostartProvider
ApplicationType Write String Adds a AutostartProvider ApplicationType
EnabledProtocols Write StringArray[] Adds EnabledProtocols on an Application http, https, net.tcp, net.msmq, net.pipe

MSFT_xWebApplicationAuthenticationInformation

Parameters

Parameter Attribute DataType Description Allowed Values
Anonymous Write Boolean Enable anonymous authentication
Basic Write Boolean Enable basic authentication
Digest Write Boolean Enable digest authentication
Windows Write Boolean Enable Windows authentication

Description

The xWebApplication DSC resource is used to...

Requirements

  • Target machine must be running Windows Server 2012 R2 or later.

Known issues

All issues are not listed here, see here for all open issues.

Examples

Example 1

Create a new web application on the Default Web Site This example shows how to use the xWebApplication DSC resource to create a new web application.

Configuration Sample_xWebApplication_NewWebApplication
{
    param
    (
        # Target nodes to apply the configuration
        [String[]] $NodeName = 'localhost',

        # Destination path for Website content
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [String] $DestinationPath
    )

    # Import the module that defines custom resources
    Import-DscResource -Module PSDesiredStateConfiguration
    Import-DscResource -Module xWebAdministration

    Node $NodeName
    {
        # Install the IIS role
        WindowsFeature IIS
        {
            Ensure                  = 'Present'
            Name                    = 'Web-Server'
        }

        # Install the ASP .NET 4.5 role
        WindowsFeature AspNet45
        {
            Ensure                  = 'Present'
            Name                    = 'Web-Asp-Net45'
        }

        # Start the Default Web Site
        xWebSite DefaultSite
        {
            Ensure                  = 'Present'
            Name                    = 'Default Web Site'
            State                   = 'Started'
            PhysicalPath            = 'C:\inetpub\wwwroot'
            DependsOn               = '[WindowsFeature]IIS'
        }

        # Create a new application pool for the application
        xWebAppPool SampleAppPool
        {
            Ensure                  = 'Present'
            Name                    = 'SampleAppPool'
        }

        # Clone the wwwroot folder to the destination
        File WebContent
        {
            Ensure                  = 'Present'
            SourcePath              = 'C:\inetpub\wwwroot'
            DestinationPath         = $DestinationPath
            Recurse                 = $true
            Type                    = 'Directory'
            DependsOn               = '[WindowsFeature]IIS'
        }

        # Create a new web application with Windows Authentication
        xWebApplication SampleApplication
        {
            Ensure                  = 'Present'
            Name                    = 'SampleApplication'
            WebAppPool              = 'SampleAppPool'
            Website                 = 'Default Web Site'
            PreloadEnabled          = $true
            ServiceAutoStartEnabled = $true
            AuthenticationInfo      = MSFT_xWebApplicationAuthenticationInformation
            {
                Anonymous   = $false
                Basic       = $false
                Digest      = $false
                Windows     = $true
            }
            SslFlags                = ''
            PhysicalPath            = $DestinationPath
            DependsOn               = '[xWebSite]DefaultSite','[xWebAppPool]SampleAppPool'
        }
    }
}

Example 2

This shows an example for all possible settings for the xWebApplication resource

configuration Sample_xWebApplication
{

    param
    (
        # Target nodes to apply the configuration
        [String[]] $NodeName = 'localhost',

        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [String] $PhysicalPath
    )

    Import-DscResource -ModuleName xWebAdministration

    node $NodeName
    {
        xWebApplication WebApplication
        {
            Website                  = 'Website'
            Ensure                   = 'Present'
            Name                     = 'WebApplication'
            PhysicalPath             = $PhysicalPath
            WebAppPool               = 'DefaultAppPool'
            ApplicationType          = 'ApplicationType'
            AuthenticationInfo       = `
                MSFT_xWebApplicationAuthenticationInformation
            {
                Anonymous = $true
                Basic     = $false
                Digest    = $false
                Windows   = $false
            }
            PreloadEnabled           = $true
            ServiceAutoStartEnabled  = $true
            ServiceAutoStartProvider = 'ServiceAutoStartProvider'
            SslFlags                 = @('Ssl')
            EnabledProtocols         = @('http', 'net.tcp')
        }
    }
}