MCSA Notes 70-740 P1

DSC Configuration

DSC is a management platform in PowerShell that enables you to manage your IT and development infrastructure with configuration as code. Below we create a configuration file to install IIS and support Remote Management.

# Create a DSC configuration to install IIS and support remote management
Configuration IISConfig {

# Define input parameter
param(
[string[]]$ComputerName = 'localhost'
)

# Target machine(s) based on input param
node $ComputerName {

# Install the IIS server role
WindowsFeature IIS {
Ensure = "Present"
Name = "Web-Server"
}

# Install the IIS remote management service
WindowsFeature IISManagement {
Name = 'Web-Mgmt-Service'
Ensure = 'Present'
DependsOn = @('[WindowsFeature]IIS')
}

# Enable IIS remote management
Registry RemoteManagement {
Key = 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server'
ValueName = 'EnableRemoteManagement'
ValueType = 'Dword'
ValueData = '1'
DependsOn = @('[WindowsFeature]IIS','[WindowsFeature]IISManagement')
}

# Configure remote management service
Service WMSVC {
Name = 'WMSVC'
StartupType = 'Automatic'
State = 'Running'
DependsOn = '[Registry]RemoteManagement'
}

}

}

# Create the configuration (.mof)
IISConfig -ComputerName WEB-NUG -OutputPath c:\nuggetlab

# push the configuration to WEB-NUG
Start-DscConfiguration -Path c:\nuggetlab -Wait -Verbose

# enter powershell remote session
Enter-PSSession -ComputerName WEB-NUG

# view installed features
Get-WindowsFeature | Where-Object Installed -eq True

# view LCM properties
Get-DscLocalConfigurationManager

# view configuration state
Get-DscConfigurationStatus

# test configuration drift
Test-DscConfiguration

# exit powershell remote session
Exit-PSSession

Ersten Kommentar schreiben

Antworten

Deine E-Mail-Adresse wird nicht veröffentlicht.


*