Configure IIS with DSC

Not happy with the default installation of IIS? Do you fancy a more “clean” approach? Read on!


This post is part of a series, at the bottom you find links to the other parts. In this part we will take the next step into making your environment configurations even more manageable.

First step is to configure our environment as descibed in the previous post.

Install modules
Install-Module xWebAdministration 
Create partial configurations

Now let’s create the IIS blueprint: InstallIIS

# A configuration to install default IIS instance
Configuration InstallIIS
	Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
	WindowsFeature IIS {
		Ensure = "Present"
		Name = "Web-Server" 
	WindowsFeature IISManagementTools
		Ensure = "Present"
		Name = "Web-Mgmt-Tools"

Now let’s create the IIS blueprint: ConfigureIIS

# A configuration to configure / cleanup a default IIS instance
Configuration ConfigureIIS
	Import-DscResource -ModuleName 'PSDesiredStateConfiguration','xWebAdministration'
	xWebAppPool RemoveDotNet2Pool         { Name = ".NET v2.0";            Ensure = "Absent"}
	xWebAppPool RemoveDotNet2ClassicPool  { Name = ".NET v2.0 Classic";    Ensure = "Absent"}
	xWebAppPool RemoveDotNet45Pool        { Name = ".NET v4.5";            Ensure = "Absent"}
	xWebAppPool RemoveDotNet45ClassicPool { Name = ".NET v4.5 Classic";    Ensure = "Absent"}
	xWebAppPool RemoveClassicDotNetPool   { Name = "Classic .NET AppPool"; Ensure = "Absent"}
	xWebAppPool RemoveDefaultAppPool      { Name = "DefaultAppPool";       Ensure = "Absent"}
	xWebSite    RemoveDefaultWebSite      { Name = "Default Web Site";     Ensure = "Absent"; PhysicalPath = "C:\inetpub\wwwroot"}
The new LEGO manual

Now let’s ensemble our environment with the blueprint we have created.

Configuration ConfigureTestMachine
	PartialConfiguration AssertDC
		Description = 'Create a Domain Controller'
		RefreshMode = 'Push'

	PartialConfiguration AllowSecureRDP
		Description = 'Enable secure RDP connections'
		RefreshMode = 'Push'
		DependsOn = '[PartialConfiguration]AssertDC'

	PartialConfiguration InstallIIS
		Description = 'Install IIS'
		RefreshMode = 'Push'
		DependsOn = '[PartialConfiguration]AssertDC'

	PartialConfiguration ConfigureIIS
		Description = 'Configure IIS'
		RefreshMode = 'Push'
		DependsOn = '[PartialConfiguration]InstallIIS'
Compile the stuff into MOF files

We now have created all the script parts we need, it time to compile it all into MOF files.

# Compile the partial configuration "InstallIIS" 
InstallIIS -outputpath c:\InstallIIS

# Compile the partial configuration "ConfigureIIS" 
ConfigureIIS -outputpath c:\ConfigureIIS

# Compile the "ensamble" configuration "ConfigureTestMachine " 
ConfigureTestMachine -outputpath c:\ConfigureTestMachine
Update our DSC Configuration
Set-DscLocalConfigurationManager -Path c:\ConfigureTestMachine -Verbose
Publish-DscConfiguration -path c:\InstallIIS -verbose
Publish-DscConfiguration -path c:\ConfigureIIS -verbose
Start-DscConfiguration -UseExisting -Wait

This post is seperated into multiple parts:

  1. What is DSC?
  2. Setting up the environment for DSC
  3. Configure Active Directory with DSC
  4. What LEGO has to do with PowerShell DSC Partial Configurations!
  5. Configure IIS with DSC(this post)
  6. Install SQL with DSC
  7. Install SharePoint
  8. Configure SharePoint

2 thoughts on “Configure IIS with DSC”

  1. I have noticed you don’t monetize your website, don’t waste your traffic, you can earn extra cash every month because you’ve got high quality content.

    If you want to know how to make extra bucks, search for: Mertiso’s tips best adsense alternative


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s