Is there a way to make DSC abort its configuration attempt if an error occurs and not just proceed on to the next resource in the configuration?
Basically, I want to turn off "on error resume next" and do what chef does - abort the run on error.
if you add DependsOn to any resource you don't want to continue, it will abort if anything in the chain of dependencies has an error.
See Using DependsOn and this StackOverflow answer describing dependencies
For Example, in the configuration below, if the group fails, none of the other resources will be created, because UserExample depends on GroupExample, and UserExample2 depends on UserExample.
Configuration DependsOnExample {
Node Test-PC1 {
Group GroupExample {
Ensure = "Present"
GroupName = "TestGroup"
}
User UserExample {
Ensure = "Present"
UserName = "TestUser"
FullName = "TestUser"
DependsOn = "[Group]GroupExample"
}
User UserExample2 {
Ensure = "Present"
UserName = "TestUser2"
FullName = "TestUser2"
DependsOn = "[User]UserExample"
}
}
}
There is not currently a way to get the same behavior without an explicit dependency.
If you would like to request the feature from the product team, I suggest filing an issue in the PowerShell User Voice
Travis