Last active
April 16, 2019 17:47
-
-
Save jeffpatton1971/8198574 to your computer and use it in GitHub Desktop.
This DSC Configuration shows off several features available via DSC. It installs the Web-Server feature, and several additional web features that each depend on Web-Server being installed. It uses the Package reference to install the WebDeploy MSI, based on that path passed in the param, which also depends on Web-Server. It uses a Script referen…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration BasicWebServer | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$ComputerName, | |
[string]$Source = $null, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$WebDeployPath = $null | |
) | |
Node $ComputerName | |
{ | |
WindowsFeature WebServerRole | |
{ | |
# Installs the following features | |
<# | |
Web-Server | |
Web-WebServer | |
Web-Common-Http | |
Web-Default-Doc | |
Web-Dir-Browsing | |
Web-Http-Errors | |
Web-Static-Content | |
Web-Health | |
Web-Http-Logging | |
Web-Performance | |
Web-Stat-Compression | |
Web-Security | |
Web-Filtering | |
#> | |
Name = "Web-Server" | |
Ensure = "Present" | |
Source = $Source | |
} | |
WindowsFeature WebAppDev | |
{ | |
Name = "Web-App-Dev" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebAspNet | |
{ | |
Name = "Web-Asp-Net" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebNetExt | |
{ | |
Name = "Web-Net-Ext" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebISAPIExt | |
{ | |
Name = "Web-ISAPI-Ext" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebISAPIFilter | |
{ | |
Name = "Web-ISAPI-Filter" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebLogLibraries | |
{ | |
Name = "Web-Log-Libraries" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebRequestMonitor | |
{ | |
Name = "Web-Request-Monitor" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebMgmtTools | |
{ | |
Name = "Web-Mgmt-Tools" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WebMgmtConsole | |
{ | |
Name = "Web-Mgmt-Console" | |
Ensure = "Present" | |
Source = $Source | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
Package WebDeploy | |
{ | |
Name = "Web Deploy 3.5" | |
Path = $WebDeployPath | |
ProductId = "3674F088-9B90-473A-AAC3-20A00D8D810C" | |
Ensure = "Present" | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
Script WebDeployFwRule | |
{ | |
GetScript = | |
{ | |
# | |
# This must return at least the Result property in a hash table | |
# | |
$Rule = Get-NetFirewallRule -DisplayName "WebDeploy_TCP_8172" | |
Return @{ | |
GetScript = $GetScript | |
Result = "DisplayName = $($Rule.DisplayName); Enabled = $($Rule.Enabled)" | |
SetScript = $SetScript | |
TestScript = $TestScript | |
} | |
} | |
TestScript = | |
{ | |
# | |
# This must return either true or false | |
# | |
if (Get-NetFirewallRule -DisplayName "WebDeploy_TCP_8172" -ErrorAction SilentlyContinue) | |
{ | |
$true | |
} | |
else | |
{ | |
$false | |
} | |
} | |
SetScript = | |
{ | |
New-NetFirewallRule -DisplayName "WebDeploy_TCP_8172" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 8172 | |
} | |
DependsOn = "[Package]WebDeploy" | |
} | |
} | |
} |
This is a huge help - thanks so much for posting.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I added some light comments to the Script Resource