Detecting if DSC is currently Applying

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Codeweavers Codeweavers 1 year, 1 month ago.

  • Author
    Posts
  • #32247
    Profile photo of Codeweavers
    Codeweavers
    Participant

    Heya,

    Bit of a strange one here, we're currently moving our development environment deployment from start-up script installation to DSC in a pull configuration on Server 2012 R2. We've got everything working in-terms of the configuration script and the pull server etc however we're trying to ensure that a machine is obviously "not ready" to login to until the DSC is finished applying.

    Our original solution to this was to have a synchronous startup script that checks for the existance of "C:\Windows\System32\Configuration\Pending.mof" and while it's there just sleep and check again in 5 seconds. This *almost* works, except that the startup script executing appears to interfere with DSC's ability to reboot when it needs to. So, if I can change the loop to break out if DSC isn't applying then it'll presumably restart itself appropriately? This poses the question, how do I tell if it's currently applying stuff?!

    Thanks,
    Rob

  • #32256
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Well... off the top of my head, I'm not sure you can. At least not in the fashion you're looking for. DSC's design ethos is all about "it'll eventually be configured" and it doesn't really have a lot of hooks for checking to see what it's up to at any given moment.

    Why not set up a reporting server, let DSC report to it, and then periodically query that to see if the node has reported in as compliant?

  • #32264
    Profile photo of Codeweavers
    Codeweavers
    Participant

    Hiya Don,

    Thanks for the reply. We do have a compliance server currently, however it appears that the nodes are regarded as compliant once the pending.mof is present, not when the configuration is actually finished applying?

    I was thinking about looking for a running WmiPrvSE process, however that appears to be always banging around. I suppose another option would be to look in the EventLog maybe?

    Thanks,
    Rob

  • #32265
    Profile photo of Don Jones
    Don Jones
    Keymaster

    No, that shouldn't be the case, unless DSC has already figured out that all the Tests returned $True. That's what you're seeing, though?

    I think a better technique might be to create a short Script resource that tests to see if some flag file is present. Make it depend on everything else that you can, so that it runs last. When the file exists, it's done. Or... something else along that logic.

  • #32310
    Profile photo of Codeweavers
    Codeweavers
    Participant

    Aha!

    We have discovered the answer to our original query, I believe that (Get-DscLocalConfigurationManager).LCMState holds the answer;

    It can be Idle, Busy, PendingConfiguration, PendingReboot

You must be logged in to reply to this topic.