-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew-Website.ps1
47 lines (45 loc) · 1.47 KB
/
New-Website.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<#
.SYNOPSIS
DSC tp create a new IIS website with xWebAdministration module
.Link
Using xWebAdministration module refer from https://github.com/PowerShell/xWebAdministration
#>
Configuration New-Website
{
param
(
[string[]]$NodeName = 'localhost',
[Parameter(Mandatory)] [ValidateNotNullOrEmpty()]
[String]$WebSiteName,
[Parameter(Mandatory)] [ValidateNotNullOrEmpty()]
[String]$SourcePath,
[Parameter(Mandatory)] [ValidateNotNullOrEmpty()]
[String]$DestinationPath
)
Import-DscResource -Module xWebAdministration
Node $NodeName
{
# Copy the website content
File WebContent {
Ensure = "Present"
SourcePath = $SourcePath
DestinationPath = $DestinationPath
Recurse = $true
Type = "Directory"
Force = $true
}
# New WebSite
xWebsite NewWebsite {
Ensure = "Present"
Name = $WebSiteName
State = "Started"
PhysicalPath = $DestinationPath
BindingInfo = MSFT_xWebBindingInformation {
Protocol = "HTTP"
Port = 7001
}
}
}
}
New-Website -NodeName "localhost" -WebSiteName "TestDsc" -SourcePath "$PSScriptRoot\sampleHtml" -DestinationPath "D:\TestDscWww"
Start-DscConfiguration -Path New-Website -Verbose -Force -Wait