Last active
March 2, 2022 13:16
-
-
Save ploegert/99946004948f7e8a9b68 to your computer and use it in GitHub Desktop.
DSC Config for Web Server
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 WebSiteConfig | |
| { | |
| # Import DSC WebAdmin Module from DSC Resource Kit | |
| Import-DscResource -ModuleName xWebAdministration | |
| Node ("localhost") | |
| { | |
| # Install the Web Server role | |
| WindowsFeature IIS | |
| { | |
| Ensure = "Present" | |
| Name = "Web-Server" | |
| } | |
| # Install the ASP.NET 4.5 role | |
| WindowsFeature AspNet | |
| { | |
| Ensure = "Present" | |
| Name = "Web-Asp-Net45" | |
| } | |
| # Stop the default website | |
| xWebsite DefaultSite | |
| { | |
| Ensure = "Present" | |
| Name = "Default Web Site" | |
| State = "Stopped" | |
| PhysicalPath = "C:\inetpub\wwwroot" | |
| DependsOn = "[WindowsFeature]IIS" | |
| } | |
| # Copy web application content | |
| File MyWebAppContent | |
| { | |
| Ensure = "Present" # You can also set Ensure to "Absent" | |
| Type = "Directory" # Default is "File". | |
| Recurse = $true # Ensure presence of subdirectories, too | |
| SourcePath = "\\XXXdemoad01\source\MyWebApp" | |
| DestinationPath = "C:\inetpub\MyWebApp" | |
| DependsOn = "[WindowsFeature]AspNet" | |
| } | |
| # Install SSL Certificate | |
| Script MyWebAppCert | |
| { | |
| SetScript = "Import-PfxCertificate | |
| -FilePath \\XXXdemoad01\source\certs\MyWebAppCert.pfx | |
| -CertStoreLocation Cert:\LocalMachine\WebHosting" | |
| TestScript = "try { (Get-Item | |
| Cert:\LocalMachine\WebHosting\ | |
| C534DFBFE8DB597F22320682F7BBFBA2611DC45A | |
| -ErrorAction Stop).HasPrivateKey} catch { `$False }" | |
| GetScript = "@{Ensure = if ((Get-Item | |
| Cert:\LocalMachine\WebHosting\ | |
| C534DFBFE8DB597F22320682F7BBFBA2611DC45A | |
| -ErrorAction SilentlyContinue).HasPrivateKey) | |
| {'Present'} | |
| else {'Absent'}}" | |
| DependsOn = "[WindowsFeature]IIS" | |
| } | |
| # Create the web site for MyWebApp | |
| xWebsite MyWebAppSite | |
| { | |
| Ensure = "Present" | |
| Name = "MyWebApp" | |
| State = "Started" | |
| PhysicalPath = "C:\inetpub\MyWebApp" | |
| BindingInfo = MSFT_xWebBindingInformation | |
| { | |
| Protocol = "HTTPS" | |
| Port = 443 | |
| CertificateThumbprint = | |
| "C534DFBFE8DB597F22320682F7BBFBA2611DC45A" | |
| CertificateStoreName = "WebHosting" | |
| } | |
| DependsOn = @("[WindowsFeature]IIS", | |
| "[File]MyWebAppContent", | |
| "[Script]MyWebAppCert") | |
| } | |
| } | |
| } |
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
| Get-PackageProvider -Name NuGet -ForceBootstrap | |
| Install-Module -Repository PSGallery PackageManagementProviderResource -Force | |
| install-module -Repository PSGallery xPSDesiredStateConfiguration -force | |
| Install-Module -Name cChoco -Force | |
| #find-module -repository psgallery -name dscresource | |
| #install-module -Repository psgallery -name cChoco -Force | |
| #import-module PackageManagement | |
| #import-module PackageManagementProviderResource | |
| Configuration allinone | |
| { | |
| param ($MachineName) | |
| Import-DscResource -Module PackageManagementProviderResource | |
| Import-DscResource -Module xPSDesiredStateConfiguration | |
| Import-DscResource -ModuleName cChoco | |
| Node $MachineName | |
| { | |
| File DeployFolder | |
| { | |
| Ensure = "Present" | |
| Type = "Directory" | |
| DestinationPath = "C:\Tools\_Deploy" | |
| } | |
| File poshFolder | |
| { | |
| Ensure = "Present" | |
| Type = "Directory" | |
| DestinationPath = "C:\posh" | |
| } | |
| #Install the IIS Role | |
| WindowsFeature IIS | |
| { | |
| Ensure = "Present" | |
| Name = "Web-Server" | |
| } | |
| #Install ASP.NET 4.5 | |
| WindowsFeature ASP | |
| { | |
| Ensure = "Present" | |
| Name = "Web-Asp-Net45" | |
| } | |
| WindowsFeature WebServerManagementConsole | |
| { | |
| Name = "Web-Mgmt-Console" | |
| Ensure = "Present" | |
| } | |
| WindowsFeature TelnetClient | |
| { | |
| Name = "Telnet-Client" | |
| Ensure = "Present" | |
| } | |
| #windows Groups | |
| Group grpIISIUSRS | |
| { | |
| Ensure = "Present" | |
| GroupName = "IIS_IUSRS" | |
| Description = "IIS User Group" | |
| } | |
| Group grpInfraAdmin | |
| { | |
| Ensure = "Present" | |
| GroupName = "Infra-Admins" | |
| Description = "Administrator-Make system changes" | |
| } | |
| cChocoInstaller installChoco | |
| { | |
| InstallDir = "C:\choco" | |
| } | |
| cChocoPackageInstaller installChrome | |
| { | |
| Name = "googlechrome" | |
| DependsOn = "[cChocoInstaller]installChoco" | |
| } | |
| cChocoPackageInstaller dotnet452 | |
| { | |
| Name = "dotnet4.5.2" | |
| DependsOn = "[cChocoInstaller]installChoco" | |
| } | |
| cChocoPackageInstaller webpi | |
| { | |
| Name = "webpi" | |
| DependsOn = "[cChocoInstaller]installChoco" | |
| } | |
| cChocoPackageInstaller webpicommandline | |
| { | |
| Name = "webpicommandline" | |
| DependsOn = "[cChocoInstaller]installChoco" | |
| } | |
| cChocoPackageInstaller notepad2 | |
| { | |
| Name = "notepad2" | |
| DependsOn = "[cChocoInstaller]installChoco" | |
| } | |
| Package CouchDB | |
| { | |
| Ensure = "Present" | |
| Name = "Apache CouchDB 1.6.1" | |
| Path = "http://apache.mirrors.lucidnetworks.net/couchdb/binary/win/1.6.1/setup-couchdb-1.6.1_R16B02.exe" | |
| ProductId = '' | |
| Arguments = '/VERYSILENT' | |
| } | |
| } | |
| } | |
| allinone -MachineName localhost | |
| Start-DscConfiguration -Path .\allinone -Wait -verbose -force | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment