Created
March 10, 2016 18:06
-
-
Save zhangxd6/8bf7586c2037b2757d39 to your computer and use it in GitHub Desktop.
exampe to install .net461 using dsc
This file contains 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 Main | |
{ | |
param([String]$machineName) | |
Import-DscResource -Module PSDesiredStateConfiguration,xWebAdministration | |
Node $machineName{ | |
#install IIS | |
WindowsFeature IIS | |
{ | |
Ensure = "Present" | |
Name = "Web-Server" | |
} | |
#install ASP | |
WindowsFeature ASP | |
{ | |
Ensure = "Present" | |
Name = "Web-Asp-Net45" | |
} | |
WindowsFeature WebServerManagementConsole | |
{ | |
Name = "Web-Mgmt-Console" | |
Ensure = "Present" | |
} | |
Script DownloadNet46 | |
{ | |
TestScript = { | |
Test-Path "C:\WindowsAzure\NDP46-KB3045560-Web.exe" | |
} | |
SetScript ={ | |
$source = "http://download.microsoft.com/download/1/4/A/14A6C422-0D3C-4811-A31F-5EF91A83C368/NDP46-KB3045560-Web.exe" | |
$dest = "C:\WindowsAzure\NDP46-KB3045560-Web.exe" | |
Invoke-WebRequest $source -OutFile $dest | |
} | |
GetScript = {@{Result = "Download.Net"}} | |
DependsOn = "[WindowsFeature]ASP" | |
} | |
Package InstallNETFramework | |
{ | |
Ensure = "Present" | |
Path = "C:\WindowsAzure\NDP46-KB3045560-Web.exe" | |
Name = "Microsoft .Net Framework 4.6" | |
ProductId = "" | |
Arguments = " /Passive /Noretart /Log C:\WindowsAzure\Logs\Net46.txt" | |
DependsOn = "[Script]DownloadNet46" | |
} | |
Script DownloadArtificats | |
{ | |
TestScript = { | |
$false | |
} | |
SetScript ={ | |
$source = "https://yourazure.blob.core.windows.net/configuration/artifacts.zip" | |
$dest = "C:\WindowsAzure\artifacts.zip" | |
Invoke-WebRequest $source -OutFile $dest | |
Add-Type -assembly "system.io.compression.filesystem" | |
[io.compression.zipfile]::ExtractToDirectory("C:\WindowsAzure\artifacts.zip","C:\WindowsAzure") | |
} | |
GetScript = {@{Result = "DownloadArtificat"}} | |
} | |
xWebsite DefaultSite | |
{ | |
Ensure = "Present" | |
Name = "Default Web Site" | |
State = "Started" | |
PhysicalPath = "C:\inetpub\wwwroot" | |
DependsOn = "[WindowsFeature]IIS" | |
} | |
File WebContent | |
{ | |
Ensure = "Present" | |
SourcePath = "C:\WindowsAzure\web" | |
DestinationPath = "C:\inetpub\wwwroot" | |
Recurse = $true | |
Type = "Directory" | |
DependsOn = "[Script]DownloadArtificats","[xWebsite]DefaultSite" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment