-
Notifications
You must be signed in to change notification settings - Fork 149
WebVirtualDirectory
dscbot edited this page Jul 7, 2024
·
3 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
Website | Key | String | Name of website with which Web Application is associated | |
WebApplication | Key | String | Web application name for the virtual directory | |
Name | Key | String | Name of virtual directory | |
PhysicalPath | Required | String | Physical path for the virtual directory | |
Credential | Write | PSCredential | Credential to use for accessing the virtual directory | |
Ensure | Write | String | Whether virtual directory should be present or absent |
Present , Absent
|
The WebVirtualDirectory
DSC resource is used to...
- Target machine must be running Windows Server 2012 R2 or later.
All issues are not listed here, see here for all open issues.
Create a new web virtual directory on the Default Web Site This example shows how to use the WebVirtualDirectory DSC resource to create a new virtual directory on the Default Web Site with a UNC path that requires credentials.
configuration Sample_WebVirtualDirectory_NewVirtualDirectory_WithUncPath
{
param
(
# Target nodes to apply the configuration
[System.String[]]
$NodeName = 'localhost',
# Name of virtual directory to create
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[System.String]
$VirtualDirectoryName,
# Physical path of the virtual directory
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[System.String]
$PhysicalPath,
# Credential to use for the virtual directory
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[PSCredential]
$Credential
)
# Import the module that defines custom resources
Import-DscResource -Module PSDesiredStateConfiguration
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
# Install the IIS role
WindowsFeature IIS
{
Ensure = 'Present'
Name = 'Web-Server'
}
# Start the default website
WebSite DefaultSite
{
Ensure = 'Present'
Name = 'Default Web Site'
State = 'Started'
PhysicalPath = 'C:\inetpub\wwwroot'
DependsOn = '[WindowsFeature]IIS'
}
# Copy the virtual directory content
File VirtualDirectoryContent
{
Ensure = 'Present'
DestinationPath = $PhysicalPath
Type = 'Directory'
DependsOn = '[WindowsFeature]IIS'
}
# Create the new virtual directory
WebVirtualDirectory NewVirtualDirectory
{
Ensure = 'Present'
Website = "Default Web Site"
WebApplication = ''
Name = $VirtualDirectoryName
PhysicalPath = $PhysicalPath
DependsOn = '[File]VirtualDirectoryContent'
Credential = $Credential
}
}
}
Create a new web virtual directory on the Default Web Site This example shows how to use the WebVirtualDirectory DSC resource to create a new virtual directory on the Default Web Site.
configuration Sample_WebVirtualDirectory_NewVirtualDirectory
{
param
(
# Target nodes to apply the configuration
[System.String[]]
$NodeName = 'localhost',
# Name of virtual directory to create
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[System.String]
$VirtualDirectoryName,
# Physical path of the virtual directory
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[System.String]
$PhysicalPath
)
# Import the module that defines custom resources
Import-DscResource -Module PSDesiredStateConfiguration
Import-DscResource -Module WebAdministrationDsc
Node $NodeName
{
# Install the IIS role
WindowsFeature IIS
{
Ensure = 'Present'
Name = 'Web-Server'
}
# Start the default website
WebSite DefaultSite
{
Ensure = 'Present'
Name = 'Default Web Site'
State = 'Started'
PhysicalPath = 'C:\inetpub\wwwroot'
DependsOn = '[WindowsFeature]IIS'
}
# Copy the virtual directory content
File VirtualDirectoryContent
{
Ensure = 'Present'
DestinationPath = $PhysicalPath
Type = 'Directory'
DependsOn = '[WindowsFeature]IIS'
}
# Create the new virtual directory
WebVirtualDirectory NewVirtualDirectory
{
Ensure = 'Present'
Website = "Default Web Site"
WebApplication = ''
Name = $VirtualDirectoryName
PhysicalPath = $PhysicalPath
DependsOn = '[File]VirtualDirectoryContent'
}
}
}
- Home
- IisFeatureDelegation
- IisLogging
- IisMimeTypeMapping
- IisModule
- SslSettings
- WebApplication
- WebApplicationHandler
- WebAppPool
- WebAppPoolDefaults
- WebConfigProperty
- WebConfigPropertyCollection
- WebSite
- WebSiteDefaults
- WebVirtualDirectory
- xIisFeatureDelegation
- xIisHandler
- xIisLogging
- xIisMimeTypeMapping
- xIisModule
- xSslSettings
- xWebApplication
- xWebAppPool
- xWebAppPoolDefaults
- xWebConfigKeyValue
- xWebConfigProperty
- xWebConfigPropertyCollection
- xWebSite
- xWebSiteDefaults
- xWebVirtualDirectory