ApplyAndAutoCorrect Question

I’m currently working on some DSC for our test server.

At the moment, my plan is to set the LCM to run in ApplyAndAutoCorrect mode, making sure to install certain images if they are not already there.

However, because this is a test server, we use it for much more than just these images. We are also using it to test things such as new domain names, azure AD connect, etc.

If I use ApplyAndAutoCorrect, I know that my images will always be present and created exactly as I want them, even if the files are accidentally deleted.

My question is, will ApplyAndAutoCorrect also delete changes made, such as adding other VM’s to the server, or adding more folders to the directories where it is applied?

If this is the case, then I’ll probably just have to create scripts to re-build the VM’s rather than force them to be created and present through DSC on the server.

Thank you very much!

Can you elaborate your scenario a bit more?
Generally speaking if you are able to capture for final state in a document it would work. Example if you do not care about certain folders/files within the image, keep them out of the configuration. You have way to capture states like:

  1. Something should be present.
  2. Something shouldn’t be present.
  3. Don’t care as this is not part of my configuration.

The scenario is as follows:

  • We have a server that holds some Golden Images for image deployment, but it is also used for testing, so we have various test machines that we spin up and delete.
  • The images need to be rebuilt for every Windows 10 Feature Update.
  • DSC could be used to help "destroy and deploy" these images, but it might destroy any other VM that we create if the LCM is told to ApplyAndAutoCorrect for those images.

My question is, if I use DSC to create these images on the server, and then I add extra VM’s to the server for testing, will those VM’s be destroyed, or will DSC not care about anything other than the specific directories and changes to the things I tell it?

The really direct answer is that DSC will run the script included in the resources during Set. The only way to be absolutely sure is to read and understand the script and think through how it will interact with your environment. ApplyandAutocorrect mode will allow DSC to run Set if Test fails in the future, as opposed to ApplyandMonitor that would write to the event log on drift but not take action, or ApplyOnly that will apply the configuration once and not check for drift.