Configuration MyConfiguration
{
# Import-DSCResource is a keyword and not a PS-command
Import-DSCResource -Module @('WindowsFeature','File','RemoteRegistry')
Node Computername {
WindowsFeature Backup {
Name="Windows-Server-Backup"
Ensure="Present"
}
File Development {
Type="Directory"
Ensure="Present"
DestinationPath="C:\Development"
}
Service RemoteRegistry {
Name="RemoteRegistry",
Startup="Automatic"
State="Running"
}
}
Node @("Server1", "Server2") {
# ...
}
}
# Load configuration
. .\MyConfiguration.ps1
# Create MOF file
MyConfiguration
# Execute configuration on computer
Start-DscConfiguration -Path .\MyConfiguration
Configuration MyConfiguration
{
Param(
[string[]]$Computername,
[string[]]$Services
)
Node @($Computername) {
# ...
}
foreach ($computer in $Computername){
# ...
}
}
$ConfigurationData = @{
AllNodes = @( # required key
@{NodeName = "FP-123"; Role = "FilePrint"},
@{NodeName = "WS-421"; Role = "WebServer"},
@{NodeName = "*"; Features = "Windows-Server-Backup","PowerShell-V4"}
);
MyData = @{ # optional arbitrarily named key
MyData = Import-CSV "C:\Development\Translations.csv"
}
}
Configuration MyConfiguration
{
Node $AllNodes.Nodename {
$Node.features.foreach({
WindowsFeature $_ {
Name = $_
Ensure = "Present"
}
})
Service RemoteRegistry {
Name = "RemoteRegistry",
StartupType = "Automatic"
State = "Running"
}
}
}
. .\MyConfig\MyConfig.ps1
MyConfiguration -ConfigurationData .\MyConfig\MyConfiguration.psd1 -OutputPath .