PowerShell DSC – Enable Web-Server, Windows Feature

email me

Show more about DSC...

 

Using a DSC script, install the Web Server Windows feature, start configuration, and view configuration.

* available only on the Server platform

 

The basic processing works like this:

make a declarative script > generate mof > apply mof > verify configuration is running


Code

Set-Location "C:\DSC\"

configuration FeatureExample
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node localhost
{

WindowsFeatureSet FeaturExample
{
Name                    = @("Web-Server")
Ensure                  = 'Present'
IncludeAllSubFeature    = $true
}
}
}

FeatureExample

Start-DscConfiguration -Path FeatureExample -ComputerName localhost -Wait -Verbose -Force

 


Notes

Install-Module -Name PSDesiredStateConfiguration
winrm quickconfig

Desired State Configuration Overview for Engineers

PSDesiredStateConfiguration

Get-DscConfiguration

DSC mofs C:\Windows\System32\Configuration