/
DSCConfiguration.ps1
103 lines (81 loc) · 2.88 KB
/
DSCConfiguration.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
configuration webConfiguration
{
param (
[Parameter(Mandatory = $False)]
[String]$PackageLocation
)
Import-DscResource -ModuleName PSDesiredStateConfiguration
# Import-DscResource -ModuleName WebAdministration
Node 'localhost'
{
# Install IIS features
WindowsFeature WebServerRole {
Name = "Web-Server"
Ensure = "Present"
}
WindowsFeature WebManagementService {
Name = "Web-Mgmt-Service"
Ensure = "Present"
}
WindowsFeature ASPNet45 {
Name = "Web-Asp-Net45"
Ensure = "Present"
}
WindowsFeature HTTPRedirection {
Name = "Web-Http-Redirect"
Ensure = "Present"
}
WindowsFeature CustomLogging {
Name = "Web-Custom-Logging"
Ensure = "Present"
}
WindowsFeature LogginTools {
Name = "Web-Log-Libraries"
Ensure = "Present"
}
WindowsFeature RequestMonitor {
Name = "Web-Request-Monitor"
Ensure = "Present"
}
WindowsFeature Tracing {
Name = "Web-Http-Tracing"
Ensure = "Present"
}
WindowsFeature BasicAuthentication {
Name = "Web-Basic-Auth"
Ensure = "Present"
}
WindowsFeature WindowsAuthentication {
Name = "Web-Windows-Auth"
Ensure = "Present"
}
WindowsFeature ApplicationInitialization {
Name = "Web-AppInit"
Ensure = "Present"
}
if (![String]::IsNullOrEmpty($websitePackageUri)) {
# Download and unpack the website into the default website
Script DeployWebPackage {
GetScript = {@{Result = "DeployWebPackage"}}
TestScript = {
return Test-Path -Path "C:\WebApp\Site.zip";
}
SetScript = {
if (!(Test-Path -Path "C:\WebApp")) {
New-Item -Path "C:\WebApp" -ItemType Directory -Force | Out-Null;
}
$dest = "C:\WebApp\Site.zip"
if (Test-Path -Path "C:\inetpub\wwwroot") {
Remove-Item -Path "C:\inetpub\wwwroot" -Force -Recurse -ErrorAction SilentlyContinue | Out-Null;
}
if (!(Test-Path -Path "C:\inetpub\wwwroot")) {
New-Item -Path "C:\inetpub\wwwroot" -ItemType Directory -Force | Out-Null;
}
Invoke-WebRequest -Uri $using:websitePackageUri -OutFile $dest -UseBasicParsing;
Expand-Archive -Path $dest -DestinationPath "C:\inetpub\wwwroot" -Force;
}
DependsOn = "[WindowsFeature]WebServerRole"
}
}
}
}