Setting 'RebootIfNeeded' throughout the Configuration

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Jacqueline Porter Jacqueline Porter 3 weeks, 3 days ago.

  • Author
    Posts
  • #69807
    Profile photo of Jacqueline Porter
    Jacqueline Porter
    Participant

    Dear all,
    I have a huge configuration of an application development server that needs to reboot a few times.
    I've configured the LCM with 'RebootNodeIfNeeded = $True' and I'm using xPendingReboot to control the reboots throughout the config. I'm not using a pull server.

    At some point in the config I don't want the node to auto-reboot anymore. But AFAIK I can only change the RebootNodeIfNeeded setting by running Set-DscLocalConfigurationManager again.

    I tried something like this:

    Script DisableAutoReboot {  
        SetScript  = {
            Set-DscLocalConfigurationManager -Path c:\DSC\DisableAutoReboot
        }
        TestScript = {
        $val = $True
        If ((Get-DscLocalConfigurationManager).RebootNodeIfNeeded) {
                 $val = $False
            }
        return $val
        }
        GetScript  = {
            @{Result = (Get-DscLocalConfigurationManager).RebootNodeIfNeeded}
            }
        }
       }
     }
    

    But then I get: The Start-DscConfiguration cmdlet is in progress and must return before Set-DscLocalConfigurationManager can be invoked.

    My question is, is this even possible? Apologies if this is a beginner question.

    Jacqueline

  • #69808
    Profile photo of Don Jones
    Don Jones
    Keymaster

    It's really not. You're correct in that you have to reconfigure the LCM, and you can't do that while it's processing a configuration. The most you could do is manually inject a new meta-MOF, but it wouldn't be processed until the next run.

    • #69838
      Profile photo of Jacqueline Porter
      Jacqueline Porter
      Participant

      Thanks for the answer. I will break up the Configuration in smaller pieces then.

You must be logged in to reply to this topic.