I have just recently deployed a DSC pull server on Server 2012 R2 with PS 5.0. I am using 2 x Server 2012 R2 test servers with PS 4.0 installed to test configurations. HTTPS pull is configured and everything is running smoothly, except when I add some lines to my configuration file to check for services.
I have the following code below using some examples from the MVA DSC videos with nested configurations (services (1)) and just straight service checks (2). If I comment out the service checks, everything works great. If I add either method for service checks, the .mof and checksum files are downloaded correctly on each node (verified in C:\Windows\Temp\xxxxx) and I can see where it looks like it should be working. However the LCMState just stays at (Busy) or (PendingConfiguration) for either node and nothing ever happens (no changes made at all from the .mof file). The event logs look okay too. As soon as I comment out the service checks and rebuild the .mof files, it goes back to working great. Any ideas?
I am still just trying to learn the syntax and principals behind building these .mof files so any pointers would be greatly appreciated!
# Nested Configuration (1)
Configuration RunningServices
{
param([Parameter()]$Services)
foreach ($Service in $Services) {
Service $Service
{
Name = $Service
State = "Running"
Ensure = "Present"
}
}
}
Configuration ServerConfigurations
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node $AllNodes.NodeName
{
#Windows Features ---------------------------------------------------------------
WindowsFeature SNMP
{
Ensure = “Present”
Name = “SNMP-Service”
}
WindowsFeature SNMPWMI
{
Ensure = “Present”
Name = “SNMP-WMI-Provider”
}
WindowsFeature TelnetClient
{
Ensure = “Present”
Name = “Telnet-Client”
}
WindowsFeature XPS
{
Ensure = “Present”
Name = “XPS-Viewer”
}
#Services -----------------------------------------------------------------------
# Simple Service Call - Not Working (2)
Service SNMPSvc
{
Name = "SNMP"
State = "Running"
Ensure = "Present"
DependsOn = "[WindowsFeature]SNMP" #Tried with and without this line
}
Service WINRMSvc
{
Name = "WINRM"
State = "Running"
Ensure = "Present"
}
# Nested Configuration - Not Working (1)
RunningServices BaseServices
{
Services = "WINRM","SNMP"
}
}
Node $AllNodes.Where{$_.Role -like "SQLServer"}.NodeName
{
WindowsFeature SMTP
{
Ensure = “Absent”
Name = “SMTP-Server”
}
}
Node $AllNodes.Where{$_.Role -like "WebServer"}.NodeName
{
}
#SNMP Contact Strings --------------------------------------------------------------
Node $AllNodes.Where{$_.Role -like "Test"}.NodeName
{
Registry SNMPString {
Ensure = "Present"
Key = "HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent"
ValueName = "sysContact"
ValueData = "Test Server"
ValueType = "String"
}
}
}